Skip to content
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
2 changes: 1 addition & 1 deletion src/components/AvatarWithDisplayName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function AvatarWithDisplayName({
const title = getReportName(report, reportAttributes);
const isParentReportArchived = useReportIsArchived(report?.parentReportID);
const subtitle = getChatRoomSubtitle(report, policy, conciergeReportID, translate, true, isReportArchived);
const parentNavigationSubtitleData = getParentNavigationSubtitle(report, policy, conciergeReportID, isParentReportArchived, reportAttributes);
const parentNavigationSubtitleData = getParentNavigationSubtitle(report, policy, conciergeReportID, translate, isParentReportArchived, reportAttributes);
const isMoneyRequestOrReport = isMoneyRequestReport(report) || isMoneyRequest(report) || isTrackExpenseReport(report) || isInvoiceReport(report);
const ownerPersonalDetails = getPersonalDetailsForAccountIDs(report?.ownerAccountID ? [report.ownerAccountID] : [], personalDetails);
const displayNamesWithTooltips = getDisplayNamesWithTooltips(Object.values(ownerPersonalDetails), false, localeCompare, formatPhoneNumber);
Expand Down
9 changes: 5 additions & 4 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6054,6 +6054,7 @@ function getParentNavigationSubtitle(
report: OnyxEntry<Report>,
policy: OnyxEntry<Policy>,
conciergeReportID: string | undefined,
translate: LocalizedTranslate,
isParentReportArchived = false,
reportAttributes?: ReportAttributesDerivedValue['reports'],
): ParentNavigationSummaryParams {
Expand All @@ -6068,8 +6069,8 @@ function getParentNavigationSubtitle(

if (isExpenseReport(report)) {
return {
reportName: translateLocal('workspace.common.policyExpenseChatName', reportOwnerDisplayName ?? ''),
workspaceName: getPolicyName({report, policy}),
reportName: translate('workspace.common.policyExpenseChatName', reportOwnerDisplayName ?? ''),
workspaceName: getPolicyName({report, policy, unavailableTranslation: translate('workspace.common.unavailable')}),
};
}
if (isIOUReport(report)) {
Expand All @@ -6079,7 +6080,7 @@ function getParentNavigationSubtitle(
}

if (isInvoiceReport(report) || isInvoiceRoom(parentReport)) {
const senderWorkspaceName = getPolicyName({report: parentReport, policy});
const senderWorkspaceName = getPolicyName({report: parentReport, policy, unavailableTranslation: translate('workspace.common.unavailable')});
const invoiceReceiverPolicyID = getInvoiceReceiverPolicyID(parentReport);
const invoiceReceiverPolicy = invoiceReceiverPolicyID ? allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${invoiceReceiverPolicyID}`] : undefined;
const isCurrentUserReceiver = isCurrentUserInvoiceReceiver(parentReport);
Expand All @@ -6091,7 +6092,7 @@ function getParentNavigationSubtitle(
}

if (isArchivedNonExpenseReport(parentReport, isParentReportArchived)) {
reportName += ` (${translateLocal('common.archived')})`;
reportName += ` (${translate('common.archived')})`;
}

return {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/DynamicReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ function DynamicReportDetailsPage({policy, report, route, reportMetadata, report
const isReportArchived = useReportIsArchived(report?.reportID);
const isArchivedRoom = useMemo(() => isArchivedNonExpenseReport(report, isReportArchived), [report, isReportArchived]);
const shouldDisableRename = useMemo(() => shouldDisableRenameUtil(report, isReportArchived), [report, isReportArchived]);
const parentNavigationSubtitleData = getParentNavigationSubtitle(report, policy, conciergeReportID, isParentReportArchived);
const parentNavigationSubtitleData = getParentNavigationSubtitle(report, policy, conciergeReportID, translate, isParentReportArchived);
const base62ReportID = getBase62ReportID(Number(report.reportID));
const ancestors = useAncestors(report);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/ShareCodePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function ShareCodePage({report, policy, backTo}: ShareCodePageProps) {
}

return (
getParentNavigationSubtitle(report, policy, conciergeReportID, isParentReportArchived).workspaceName ??
getParentNavigationSubtitle(report, policy, conciergeReportID, translate, isParentReportArchived).workspaceName ??
getChatRoomSubtitle(report, policy, conciergeReportID, translate, false, isReportArchived)
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/inbox/HeaderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function HeaderView({onNavigationMenuButtonClicked, reportID}: HeaderViewProps)
? getReportStatusTooltipTranslation({stateNum: reportHeaderData?.stateNum, statusNum: reportHeaderData?.statusNum, translate})
: undefined;
const isParentReportHeaderDataArchived = useReportIsArchived(reportHeaderData?.parentReportID);
const parentNavigationSubtitleData = getParentNavigationSubtitle(parentNavigationReport, policy, conciergeReportID, isParentReportHeaderDataArchived);
const parentNavigationSubtitleData = getParentNavigationSubtitle(parentNavigationReport, policy, conciergeReportID, translate, isParentReportHeaderDataArchived);
const humanAgentAccountID = getHumanAgentAccountIDFromReportAction(parentReportAction);
const humanAgentName = getHumanAgentFirstName(parentReportAction, personalDetails);
const reportDescription = StringUtils.lineBreaksToSpaces(Parser.htmlToText(getReportDescription(report)));
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3192,13 +3192,13 @@ describe('ReportUtils', () => {
});

it('should return the correct parent navigation subtitle for the archived invoice report', () => {
const actual = getParentNavigationSubtitle(baseArchivedPolicyExpenseChat, undefined, undefined, true);
const actual = getParentNavigationSubtitle(baseArchivedPolicyExpenseChat, undefined, undefined, translateLocal, true);
const normalizedActual = {...actual, reportName: actual.reportName?.replaceAll('\u00A0', ' ')};
expect(normalizedActual).toEqual({reportName: 'A workspace & Ragnar Lothbrok (archived)'});
});

it('should return the correct parent navigation subtitle for the non archived invoice report', () => {
const actual = getParentNavigationSubtitle(baseArchivedPolicyExpenseChat, undefined, undefined, false);
const actual = getParentNavigationSubtitle(baseArchivedPolicyExpenseChat, undefined, undefined, translateLocal, false);
const normalizedActual = {...actual, reportName: actual.reportName?.replaceAll('\u00A0', ' ')};
expect(normalizedActual).toEqual({reportName: 'A workspace & Ragnar Lothbrok'});
});
Expand All @@ -3217,7 +3217,7 @@ describe('ReportUtils', () => {
role: CONST.POLICY.ROLE.ADMIN,
});

const actual = getParentNavigationSubtitle(expenseReport, testPolicy, undefined);
const actual = getParentNavigationSubtitle(expenseReport, testPolicy, undefined, translateLocal);
expect(actual.workspaceName).toBe('Direct Policy Name');
});

Expand Down Expand Up @@ -3245,14 +3245,14 @@ describe('ReportUtils', () => {
};

return Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}200`, parentInvoiceRoom).then(() => {
const actual = getParentNavigationSubtitle(invoiceReport, testPolicy, undefined);
const actual = getParentNavigationSubtitle(invoiceReport, testPolicy, undefined, translateLocal);
const normalizedActual = {...actual, reportName: actual.reportName?.replaceAll('\u00A0', ' ')};
expect(normalizedActual.reportName).toContain('Invoice Policy');
});
});

it('should fall back to allPolicies when policy parameter is undefined', () => {
const actual = getParentNavigationSubtitle(baseArchivedPolicyExpenseChat, undefined, undefined);
const actual = getParentNavigationSubtitle(baseArchivedPolicyExpenseChat, undefined, undefined, translateLocal);
const normalizedActual = {...actual, reportName: actual.reportName?.replaceAll('\u00A0', ' ')};
// Should still resolve via Onyx-connected allPolicies or report.policyName
expect(normalizedActual.reportName).toContain('A workspace');
Expand All @@ -3265,7 +3265,7 @@ describe('ReportUtils', () => {
reportName: 'Chat Report',
type: CONST.REPORT.TYPE.CHAT,
};
const actual = getParentNavigationSubtitle(chatReport, undefined, undefined);
const actual = getParentNavigationSubtitle(chatReport, undefined, undefined, translateLocal);
expect(actual).toEqual({});
});

Expand All @@ -3292,13 +3292,13 @@ describe('ReportUtils', () => {
})
.then(waitForBatchedUpdates)
.then(() => {
const actual = getParentNavigationSubtitle(childReport, undefined, conciergeReportID);
const actual = getParentNavigationSubtitle(childReport, undefined, conciergeReportID, translateLocal);
expect(actual.reportName).toBe('Concierge');
});
});

it('should return reportName and workspaceName when parent report exists and conciergeReportID is undefined', () => {
const actual = getParentNavigationSubtitle(baseArchivedPolicyExpenseChat, undefined, undefined, false);
const actual = getParentNavigationSubtitle(baseArchivedPolicyExpenseChat, undefined, undefined, translateLocal);
expect(actual).toHaveProperty('reportName');
});
});
Expand Down
Loading