diff --git a/src/components/ParentNavigationSubtitle.tsx b/src/components/ParentNavigationSubtitle.tsx index 2816715dae2c..3109453ca6b0 100644 --- a/src/components/ParentNavigationSubtitle.tsx +++ b/src/components/ParentNavigationSubtitle.tsx @@ -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(); @@ -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} > @@ -39,7 +39,7 @@ function ParentNavigationSubtitle({parentNavigationSubtitleData, parentReportID numberOfLines={1} > {`${translate('threads.from')} `} - {rootReportName} + {reportName} {Boolean(workspaceName) && {` ${translate('threads.in')} ${workspaceName}`}} diff --git a/src/languages/en.ts b/src/languages/en.ts index eb5cd1c4e3ba..4fa22d8e255d 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -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', diff --git a/src/languages/es.ts b/src/languages/es.ts index 9619c3afb4ae..7bea48d71d36 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -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', diff --git a/src/languages/types.ts b/src/languages/types.ts index edcb67307222..975dd8fd1570 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -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}; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 832784ff60e5..ef8dad6402ec 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -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' @@ -2566,39 +2561,6 @@ function getReportName(report: OnyxEntry, policy: OnyxEntry = 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): 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 */ @@ -2626,16 +2588,15 @@ function getChatRoomSubtitle(report: OnyxEntry): string | undefined { * Gets the parent navigation subtitle for the report */ function getParentNavigationSubtitle(report: OnyxEntry): 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), + }; } /**