Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/ParentNavigationSubtitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type ParentNavigationSubtitleProps = {

function ParentNavigationSubtitle({parentNavigationSubtitleData, parentReportID = '', pressableStyles}: ParentNavigationSubtitleProps) {
const styles = useThemeStyles();
const {workspaceName, rootReportName} = parentNavigationSubtitleData;
const {workspaceName, reportName} = parentNavigationSubtitleData;

const {translate} = useLocalize();

Expand All @@ -30,7 +30,7 @@ function ParentNavigationSubtitle({parentNavigationSubtitleData, parentReportID
onPress={() => {
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(parentReportID));
}}
accessibilityLabel={translate('threads.parentNavigationSummary', {rootReportName, workspaceName})}
accessibilityLabel={translate('threads.parentNavigationSummary', {reportName, workspaceName})}
role={CONST.ROLE.LINK}
style={pressableStyles}
>
Expand All @@ -39,7 +39,7 @@ function ParentNavigationSubtitle({parentNavigationSubtitleData, parentReportID
numberOfLines={1}
>
<Text style={[styles.optionAlternateText, styles.textLabelSupporting]}>{`${translate('threads.from')} `}</Text>
<Text style={[styles.optionAlternateText, styles.textLabelSupporting, styles.link]}>{rootReportName}</Text>
<Text style={[styles.optionAlternateText, styles.textLabelSupporting, styles.link]}>{reportName}</Text>
{Boolean(workspaceName) && <Text style={[styles.optionAlternateText, styles.textLabelSupporting]}>{` ${translate('threads.in')} ${workspaceName}`}</Text>}
</Text>
</PressableWithoutFeedback>
Expand Down
2 changes: 1 addition & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2171,7 +2171,7 @@ export default {
reply: 'Reply',
from: 'From',
in: 'in',
parentNavigationSummary: ({rootReportName, workspaceName}: ParentNavigationSummaryParams) => `From ${rootReportName}${workspaceName ? ` in ${workspaceName}` : ''}`,
parentNavigationSummary: ({reportName, workspaceName}: ParentNavigationSummaryParams) => `From ${reportName}${workspaceName ? ` in ${workspaceName}` : ''}`,
},
qrCodes: {
copy: 'Copy URL',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2659,7 +2659,7 @@ export default {
reply: 'Respuesta',
from: 'De',
in: 'en',
parentNavigationSummary: ({rootReportName, workspaceName}: ParentNavigationSummaryParams) => `De ${rootReportName}${workspaceName ? ` en ${workspaceName}` : ''}`,
parentNavigationSummary: ({reportName, workspaceName}: ParentNavigationSummaryParams) => `De ${reportName}${workspaceName ? ` en ${workspaceName}` : ''}`,
},
qrCodes: {
copy: 'Copiar URL',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ type OOOEventSummaryFullDayParams = {summary: string; dayCount: number; date: st

type OOOEventSummaryPartialDayParams = {summary: string; timePeriod: string; date: string};

type ParentNavigationSummaryParams = {rootReportName?: string; workspaceName?: string};
type ParentNavigationSummaryParams = {reportName?: string; workspaceName?: string};

type SetTheRequestParams = {valueName: string; newValueToDisplay: string};

Expand Down
55 changes: 8 additions & 47 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ type SpendBreakdown = {

type ParticipantDetails = [number, string, UserUtils.AvatarSource, UserUtils.AvatarSource];

type ReportAndWorkspaceName = {
rootReportName: string;
workspaceName?: string;
};

type OptimisticAddCommentReportAction = Pick<
ReportAction,
| 'reportActionID'
Expand Down Expand Up @@ -2558,39 +2553,6 @@ function getReportName(report: OnyxEntry<Report>, policy: OnyxEntry<Policy> = nu
return participantsWithoutCurrentUser.map((accountID) => getDisplayNameForParticipant(accountID, isMultipleParticipantReport)).join(', ');
}

/**
* Recursively navigates through thread parents to get the root report and workspace name.
* The recursion stops when we find a non thread or money request report, whichever comes first.
*/
function getRootReportAndWorkspaceName(report: OnyxEntry<Report>): ReportAndWorkspaceName {
if (!report) {
return {
rootReportName: '',
};
}
if (isChildReport(report) && !isMoneyRequestReport(report) && !isTaskReport(report)) {
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`] ?? null;
return getRootReportAndWorkspaceName(parentReport);
}

if (isIOURequest(report)) {
return {
rootReportName: getReportName(report),
};
}
if (isExpenseRequest(report)) {
return {
rootReportName: getReportName(report),
workspaceName: isIOUReport(report) ? CONST.POLICY.OWNER_EMAIL_FAKE : getPolicyName(report, true),
};
}

return {
rootReportName: getReportName(report),
workspaceName: getPolicyName(report, true),
};
}

/**
* Get either the policyName or domainName the chat is tied to
*/
Expand Down Expand Up @@ -2618,16 +2580,15 @@ function getChatRoomSubtitle(report: OnyxEntry<Report>): string | undefined {
* Gets the parent navigation subtitle for the report
*/
function getParentNavigationSubtitle(report: OnyxEntry<Report>): ParentNavigationSummaryParams {
if (isThread(report)) {
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`] ?? null;
const {rootReportName, workspaceName} = getRootReportAndWorkspaceName(parentReport);
if (!rootReportName) {
return {};
}

return {rootReportName, workspaceName};
const parentReport = getParentReport(report);
if (isEmptyObject(parentReport)) {
return {};
}
return {};

return {
reportName: getReportName(parentReport),
workspaceName: getPolicyName(parentReport, true),
};
}

/**
Expand Down