Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Add the workspace name to the title of the workspace chats" #50230

Merged
merged 1 commit into from
Oct 4, 2024
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
12 changes: 3 additions & 9 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3755,12 +3755,11 @@ function getReportName(
parentReportActionParam?: OnyxInputOrEntry<ReportAction>,
personalDetails?: Partial<PersonalDetailsList>,
invoiceReceiverPolicy?: OnyxEntry<Policy>,
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) {
Expand Down Expand Up @@ -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')})`;
}
Expand Down Expand Up @@ -3935,8 +3929,8 @@ function getPayeeName(report: OnyxEntry<Report>): string | undefined {
/**
* Get either the policyName or domainName the chat is tied to
*/
function getChatRoomSubtitle(report: OnyxEntry<Report>, isTitleIncludePolicyName = false): string | undefined {
if (isChatThread(report) || ((isUserCreatedPolicyRoom(report) || isDefaultRoom(report)) && isTitleIncludePolicyName)) {
function getChatRoomSubtitle(report: OnyxEntry<Report>): string | undefined {
if (isChatThread(report)) {
return '';
}
if (isSelfDM(report)) {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 3 additions & 11 deletions src/pages/home/HeaderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/SidebarTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading