Skip to content

Commit

Permalink
Add the workspace name to the title of the workspace chats
Browse files Browse the repository at this point in the history
  • Loading branch information
nyomanjyotisa committed Sep 30, 2024
1 parent 868b700 commit be1cc05
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/ReportWelcomeText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 6 additions & 5 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3760,11 +3760,12 @@ function getReportName(
parentReportActionParam?: OnyxInputOrEntry<ReportAction>,
personalDetails?: Partial<PersonalDetailsList>,
invoiceReceiverPolicy?: OnyxEntry<Policy>,
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) {
Expand Down Expand Up @@ -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;

Check failure on line 3884 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unexpected string concatenation

Check failure on line 3884 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unsafe arithmetic operation on optional chaining. It can result in NaN
}

if (isSelfDM(report)) {
Expand Down Expand Up @@ -3935,8 +3936,8 @@ function getPayeeName(report: OnyxEntry<Report>): string | undefined {
/**
* Get either the policyName or domainName the chat is tied to
*/
function getChatRoomSubtitle(report: OnyxEntry<Report>): string | undefined {
if (isChatThread(report)) {
function getChatRoomSubtitle(report: OnyxEntry<Report>, isTitleIncludePolicyName = false): string | undefined {
if (isChatThread(report) || ((isUserCreatedPolicyRoom(report) || isDefaultRoom(report)) && isTitleIncludePolicyName)) {
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 @@ -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;
Expand Down
14 changes: 11 additions & 3 deletions src/pages/home/HeaderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit be1cc05

Please sign in to comment.