diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index eac0bd7fb05a..05ee612611c8 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -66,7 +66,7 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP } if (isChatRoom) { - return translate('reportActionsView.welcomeToRoom', {roomName: report?.reportName ?? ''}); + return translate('reportActionsView.welcomeToRoom', {roomName: reportName ?? ''}); } if (isSelfDM) { diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 11c9f460569b..fd0be61d8078 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3760,11 +3760,12 @@ function getReportName( parentReportActionParam?: OnyxInputOrEntry, personalDetails?: Partial, invoiceReceiverPolicy?: OnyxEntry, + shouldIncludePolicyName = false, ): string { const reportID = report?.reportID; const cacheKey = getCacheKey(report); - if (reportID) { + if (reportID && !isUserCreatedPolicyRoom(report) && !isDefaultRoom(report)) { const reportNameFromCache = reportNameCache.get(cacheKey); if (reportNameFromCache?.reportName && reportNameFromCache.reportName === report?.reportName) { @@ -3879,8 +3880,8 @@ function getReportName( formattedName += ` (${Localize.translateLocal('common.archived')})`; } - if (isUserCreatedPolicyRoom(report) || isDefaultRoom(report)) { - formattedName = report?.policyName + ' • ' + report?.reportName; + if (shouldIncludePolicyName && (isUserCreatedPolicyRoom(report) || isDefaultRoom(report))) { + formattedName = getPolicyName(report, true) + ' • ' + report?.reportName; } if (isSelfDM(report)) { @@ -3935,8 +3936,8 @@ function getPayeeName(report: OnyxEntry): string | undefined { /** * Get either the policyName or domainName the chat is tied to */ -function getChatRoomSubtitle(report: OnyxEntry): string | undefined { - if (isChatThread(report)) { +function getChatRoomSubtitle(report: OnyxEntry, isTitleIncludePolicyName = false): string | undefined { + if (isChatThread(report) || ((isUserCreatedPolicyRoom(report) || isDefaultRoom(report)) && isTitleIncludePolicyName)) { return ''; } if (isSelfDM(report)) { diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index e120f7026fce..de0f80687a57 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -481,7 +481,7 @@ function getOptionData({ result.phoneNumber = personalDetail?.phoneNumber; } - const reportName = ReportUtils.getReportName(report, policy, undefined, undefined, invoiceReceiverPolicy); + const reportName = ReportUtils.getReportName(report, policy, undefined, undefined, invoiceReceiverPolicy, true); result.text = reportName; result.subtitle = subtitle; diff --git a/src/pages/home/HeaderView.tsx b/src/pages/home/HeaderView.tsx index d463fa1cec38..f4dd8247059e 100644 --- a/src/pages/home/HeaderView.tsx +++ b/src/pages/home/HeaderView.tsx @@ -78,8 +78,8 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto const isTaskReport = ReportUtils.isTaskReport(report); const reportHeaderData = !isTaskReport && !isChatThread && report?.parentReportID ? parentReport : report; // Use sorted display names for the title for group chats on native small screen widths - const title = ReportUtils.getReportName(reportHeaderData, policy, parentReportAction, personalDetails, invoiceReceiverPolicy); - const subtitle = ReportUtils.getChatRoomSubtitle(reportHeaderData); + const title = ReportUtils.getReportName(reportHeaderData, policy, parentReportAction, personalDetails, invoiceReceiverPolicy, true); + const subtitle = ReportUtils.getChatRoomSubtitle(reportHeaderData, true); const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(reportHeaderData); const reportDescription = ReportUtils.getReportDescriptionText(report); const policyName = ReportUtils.getPolicyName(report, true); @@ -111,7 +111,15 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto ); const renderAdditionalText = () => { - if (shouldShowSubtitle() || isPersonalExpenseChat || !policyName || !isEmptyObject(parentNavigationSubtitleData) || isSelfDM) { + if ( + shouldShowSubtitle() || + isPersonalExpenseChat || + !policyName || + !isEmptyObject(parentNavigationSubtitleData) || + isSelfDM || + ReportUtils.isUserCreatedPolicyRoom(report) || + ReportUtils.isDefaultRoom(report) + ) { return null; } return (