From 8fcb0d6346557c110f9bdae68d31b098d02e5230 Mon Sep 17 00:00:00 2001 From: Vit Horacek <36083550+mountiny@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:52:46 +0200 Subject: [PATCH] Revert "Add the workspace name to the title of the workspace chats" --- src/libs/ReportUtils.ts | 12 +++--------- src/libs/SidebarUtils.ts | 2 +- src/pages/home/HeaderView.tsx | 14 +++----------- tests/unit/SidebarTest.ts | 2 +- 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a50bdd7a10ba..8427f5d90b46 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3755,12 +3755,11 @@ function getReportName( parentReportActionParam?: OnyxInputOrEntry, personalDetails?: Partial, invoiceReceiverPolicy?: OnyxEntry, - shouldIncludePolicyName = false, ): string { const reportID = report?.reportID; const cacheKey = getCacheKey(report); - if (reportID && !isUserCreatedPolicyRoom(report) && !isDefaultRoom(report)) { + if (reportID) { const reportNameFromCache = reportNameCache.get(cacheKey); if (reportNameFromCache?.reportName && reportNameFromCache.reportName === report?.reportName && reportNameFromCache.reportName !== CONST.REPORT.DEFAULT_REPORT_NAME) { @@ -3874,11 +3873,6 @@ function getReportName( formattedName = getInvoicesChatName(report, invoiceReceiverPolicy); } - if (shouldIncludePolicyName && (isUserCreatedPolicyRoom(report) || isDefaultRoom(report))) { - const policyName = getPolicyName(report, true); - formattedName = policyName ? `${policyName} • ${report?.reportName}` : report?.reportName; - } - if (isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { formattedName += ` (${Localize.translateLocal('common.archived')})`; } @@ -3935,8 +3929,8 @@ function getPayeeName(report: OnyxEntry): string | undefined { /** * Get either the policyName or domainName the chat is tied to */ -function getChatRoomSubtitle(report: OnyxEntry, isTitleIncludePolicyName = false): string | undefined { - if (isChatThread(report) || ((isUserCreatedPolicyRoom(report) || isDefaultRoom(report)) && isTitleIncludePolicyName)) { +function getChatRoomSubtitle(report: OnyxEntry): string | undefined { + if (isChatThread(report)) { return ''; } if (isSelfDM(report)) { diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 0496bc66fe5b..4bf74f3c5fc1 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -488,7 +488,7 @@ function getOptionData({ result.phoneNumber = personalDetail?.phoneNumber ?? ''; } - const reportName = ReportUtils.getReportName(report, policy, undefined, undefined, invoiceReceiverPolicy, true); + const reportName = ReportUtils.getReportName(report, policy, undefined, undefined, invoiceReceiverPolicy); result.text = reportName; result.subtitle = subtitle; diff --git a/src/pages/home/HeaderView.tsx b/src/pages/home/HeaderView.tsx index 81ee426aa8dd..42483cc3d223 100644 --- a/src/pages/home/HeaderView.tsx +++ b/src/pages/home/HeaderView.tsx @@ -87,8 +87,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, true); - const subtitle = ReportUtils.getChatRoomSubtitle(reportHeaderData, true); + const title = ReportUtils.getReportName(reportHeaderData, policy, parentReportAction, personalDetails, invoiceReceiverPolicy); + const subtitle = ReportUtils.getChatRoomSubtitle(reportHeaderData); const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(reportHeaderData); const reportDescription = ReportUtils.getReportDescriptionText(report); const policyName = ReportUtils.getPolicyName(report, true); @@ -120,15 +120,7 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto ); const renderAdditionalText = () => { - if ( - shouldShowSubtitle() || - isPersonalExpenseChat || - !policyName || - !isEmptyObject(parentNavigationSubtitleData) || - isSelfDM || - ReportUtils.isUserCreatedPolicyRoom(report) || - ReportUtils.isDefaultRoom(report) - ) { + if (shouldShowSubtitle() || isPersonalExpenseChat || !policyName || !isEmptyObject(parentNavigationSubtitleData) || isSelfDM) { return null; } return ( diff --git a/tests/unit/SidebarTest.ts b/tests/unit/SidebarTest.ts index 443b719194b3..2c8d28c537c6 100644 --- a/tests/unit/SidebarTest.ts +++ b/tests/unit/SidebarTest.ts @@ -141,7 +141,7 @@ describe('Sidebar', () => { .then(() => { const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); - expect(displayNames.at(0)).toHaveTextContent('Vikings Policy • Report (archived)'); + expect(displayNames.at(0)).toHaveTextContent('Report (archived)'); const hintMessagePreviewText = Localize.translateLocal('accessibilityHints.lastChatMessagePreview'); const messagePreviewTexts = screen.queryAllByLabelText(hintMessagePreviewText);