From 35067bd582ad103edc8a9298a7e5c51dde958ee9 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 23 Feb 2026 12:05:15 +0700 Subject: [PATCH 1/3] refactor getReportName to have 1 param --- src/components/AvatarWithDisplayName.tsx | 2 +- .../MoneyRequestReportPreviewContent.tsx | 2 +- src/libs/ModifiedExpenseMessage.ts | 2 +- .../LocalNotification/BrowserNotifications.ts | 2 +- src/libs/ReportActionsUtils.ts | 2 +- src/libs/ReportUtils.ts | 74 ++++++++----------- src/libs/SearchQueryUtils.ts | 2 +- src/libs/SearchUIUtils.ts | 2 +- src/libs/SidebarUtils.ts | 8 +- src/libs/actions/Task.ts | 2 +- src/pages/RoomInvitePage.tsx | 2 +- src/pages/RoomMembersPage.tsx | 2 +- src/pages/ShareCodePage.tsx | 2 +- src/pages/TripChatNameEditPage.tsx | 2 +- src/pages/inbox/HeaderView.tsx | 9 ++- .../FloatingActionButtonAndPopover.tsx | 4 +- .../report/ReportAvatarModalContent.tsx | 6 +- tests/perf-test/ReportUtils.perf-test.ts | 2 +- tests/ui/MoneyRequestReportPreview.test.tsx | 2 +- tests/unit/ModifiedExpenseMessageTest.ts | 2 +- tests/unit/ReportUtilsTest.ts | 26 ++++++- 21 files changed, 86 insertions(+), 71 deletions(-) diff --git a/src/components/AvatarWithDisplayName.tsx b/src/components/AvatarWithDisplayName.tsx index 1073a9ee04fef..5e8a9e2b4a1cc 100644 --- a/src/components/AvatarWithDisplayName.tsx +++ b/src/components/AvatarWithDisplayName.tsx @@ -191,7 +191,7 @@ function AvatarWithDisplayName({ const isReportArchived = useReportIsArchived(report?.reportID); // This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850 // eslint-disable-next-line @typescript-eslint/no-deprecated - const title = getReportName(report, undefined, parentReportActionParam, personalDetails, invoiceReceiverPolicy, reportAttributes, undefined, isReportArchived); + const title = getReportName({report, parentReportActionParam, personalDetails, invoiceReceiverPolicy, reportAttributes, isReportArchived}); const isParentReportArchived = useReportIsArchived(report?.parentReportID); const subtitle = getChatRoomSubtitle(report, true, isReportArchived); const parentNavigationSubtitleData = getParentNavigationSubtitle(report, isParentReportArchived, reportAttributes); diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index b48907fced4d4..3d0925c237d64 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -812,7 +812,7 @@ function MoneyRequestReportPreviewContent({ > {/* This will be fixed as follow up https://github.com/Expensify/App/pull/75357 */} {/* eslint-disable-next-line @typescript-eslint/no-deprecated */} - {getReportName(iouReport, undefined, undefined, undefined, undefined, reportAttributes) || action.childReportName} + {getReportName({report: iouReport, reportAttributes}) || action.childReportName} diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index 2f8597a03de7e..9d5a028431003 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -197,7 +197,7 @@ function getMovedFromOrToReportMessage(translate: LocalizedTranslate, movedFromR if (movedFromReport) { // eslint-disable-next-line @typescript-eslint/no-deprecated - const originReportName = getReportName(movedFromReport); + const originReportName = getReportName({report: movedFromReport}); return translate('iou.movedFromReport', originReportName ?? ''); } } diff --git a/src/libs/Notification/LocalNotification/BrowserNotifications.ts b/src/libs/Notification/LocalNotification/BrowserNotifications.ts index 82a0321497898..47cbb0bc91346 100644 --- a/src/libs/Notification/LocalNotification/BrowserNotifications.ts +++ b/src/libs/Notification/LocalNotification/BrowserNotifications.ts @@ -115,7 +115,7 @@ export default { if (isRoomOrGroupChat) { // Will be fixed in https://github.com/Expensify/App/issues/76852 // eslint-disable-next-line @typescript-eslint/no-deprecated - const roomName = ReportUtils.getReportName(report); + const roomName = ReportUtils.getReportName({report}); title = roomName; body = `${plainTextPerson}: ${plainTextMessage}`; } else { diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 910693f3e4227..fc0cddbb65065 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1750,7 +1750,7 @@ function getMemberChangeMessageElements( const buildRoomElements = (): readonly MemberChangeMessageElement[] => { // eslint-disable-next-line @typescript-eslint/no-deprecated - const roomName = getReportNameCallback(allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${originalMessage?.reportID}`]) || originalMessage?.roomName; + const roomName = getReportNameCallback({report: allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${originalMessage?.reportID}`]}) || originalMessage?.roomName; if (roomName && originalMessage) { const preposition = isInviteAction ? ` ${translate('workspace.invite.to')} ` : ` ${translate('workspace.invite.from')} `; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 3741dc7f8a461..f37633c29669c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -942,10 +942,12 @@ type GetReportNameParams = { parentReportActionParam?: OnyxInputOrEntry; personalDetails?: Partial; invoiceReceiverPolicy?: OnyxEntry; + reportAttributes?: ReportAttributesDerivedValue['reports']; transactions?: Transaction[]; reports?: Report[]; policies?: Policy[]; isReportArchived?: boolean; + conciergeReportID?: string; }; type GetReportStatusParams = { @@ -5605,7 +5607,7 @@ function parseReportActionHtmlToText(reportAction: OnyxEntry, repo if (match[1] !== childReportID) { // This will be fixed as follow up https://github.com/Expensify/App/pull/75357 // eslint-disable-next-line @typescript-eslint/no-use-before-define, @typescript-eslint/no-deprecated - reportIDToName[match[1]] = getReportName(getReportOrDraftReport(match[1])) ?? ''; + reportIDToName[match[1]] = getReportName({report: getReportOrDraftReport(match[1])}) ?? ''; } } @@ -5697,20 +5699,9 @@ function getReportActionMessage({ * Get the title for a report. * @deprecated Moved to src/libs/ReportNameUtils.ts. */ -// eslint-disable-next-line @typescript-eslint/max-params -function getReportName( - report: OnyxEntry, - policy?: OnyxEntry, - parentReportActionParam?: OnyxInputOrEntry, - personalDetails?: Partial, - invoiceReceiverPolicy?: OnyxEntry, - reportAttributes?: ReportAttributesDerivedValue['reports'], - transactions?: Transaction[], - isReportArchived?: boolean, - reports?: Report[], - policies?: Policy[], - conciergeReportID?: string, -): string { +function getReportName(reportNameInformation: GetReportNameParams): string { + const {report, policy, parentReportActionParam, personalDetails, invoiceReceiverPolicy, reportAttributes, transactions, isReportArchived, reports, policies, conciergeReportID} = + reportNameInformation; // Check if we can use report name in derived values - only when we have report but no other params const canUseDerivedValue = report && policy === undefined && parentReportActionParam === undefined && personalDetails === undefined && invoiceReceiverPolicy === undefined && isReportArchived === undefined; @@ -5744,7 +5735,7 @@ function getReportName( const {originalID} = getOriginalMessage(parentReportAction) ?? {}; const originalReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${originalID}`]; // eslint-disable-next-line @typescript-eslint/no-deprecated -- temporarily disabling rule for deprecated functions out of issue scope - const reportName = getReportName(originalReport); + const reportName = getReportName({report: originalReport}); // eslint-disable-next-line @typescript-eslint/no-deprecated -- temporarily disabling rule for deprecated functions out of issue scope return getCreatedReportForUnapprovedTransactionsMessage(originalID, reportName, translateLocal); } @@ -5924,18 +5915,17 @@ function getSearchReportName(props: GetReportNameParams): string { if (isExpenseReport(currentParent)) { // eslint-disable-next-line @typescript-eslint/no-deprecated - return getReportName( - currentParent, + return getReportName({ + report: currentParent, policy, - props.parentReportActionParam, - props.personalDetails, - props.invoiceReceiverPolicy, - undefined, - props.transactions, - props.isReportArchived, - props.reports, - props.policies, - ); + parentReportActionParam: props.parentReportActionParam, + personalDetails: props.personalDetails, + invoiceReceiverPolicy: props.invoiceReceiverPolicy, + transactions: props.transactions, + isReportArchived: props.isReportArchived, + reports: props.reports, + policies: props.policies, + }); } // Continue traversing up the parent chain @@ -5946,18 +5936,17 @@ function getSearchReportName(props: GetReportNameParams): string { } // This will be fixed as follow up https://github.com/Expensify/App/pull/75357 // eslint-disable-next-line @typescript-eslint/no-deprecated - return getReportName( + return getReportName({ report, policy, - props.parentReportActionParam, - props.personalDetails, - props.invoiceReceiverPolicy, - undefined, - props.transactions, - props.isReportArchived, - props.reports, - props.policies, - ); + parentReportActionParam: props.parentReportActionParam, + personalDetails: props.personalDetails, + invoiceReceiverPolicy: props.invoiceReceiverPolicy, + transactions: props.transactions, + isReportArchived: props.isReportArchived, + reports: props.reports, + policies: props.policies, + }); } /** @@ -6100,7 +6089,7 @@ function getParentNavigationSubtitle(report: OnyxEntry, isParentReportAr return { // This will be fixed as follow up https://github.com/Expensify/App/pull/75357 // eslint-disable-next-line @typescript-eslint/no-deprecated - reportName: getReportName(parentReport, undefined, undefined, undefined, undefined, reportAttributes), + reportName: getReportName({report: parentReport, reportAttributes}), workspaceName: getPolicyName({report: parentReport, returnEmptyIfNotFound: true}), }; } @@ -6847,7 +6836,7 @@ function getMovedTransactionMessage(translate: LocalizedTranslate, action: Repor // This will be fixed as follow up https://github.com/Expensify/App/pull/75357 // eslint-disable-next-line @typescript-eslint/no-deprecated - const reportName = getReportName(report) ?? report?.reportName ?? ''; + const reportName = getReportName({report}) ?? report?.reportName ?? ''; const reportUrl = getReportURLForCurrentContext(report?.reportID); if (typeof fromReportID === 'undefined') { return translate('iou.movedTransactionTo', reportUrl, reportName); @@ -6863,7 +6852,7 @@ function getUnreportedTransactionMessage(translate: LocalizedTranslate, action: // This will be fixed as follow up https://github.com/Expensify/App/pull/75357 // eslint-disable-next-line @typescript-eslint/no-deprecated - const reportName = getReportName(fromReport) ?? fromReport?.reportName ?? ''; + const reportName = getReportName({report: fromReport}) ?? fromReport?.reportName ?? ''; let reportUrl = getReportURLForCurrentContext(fromReportID); @@ -12456,12 +12445,12 @@ function getChatListItemReportName(action: ReportAction & {reportName?: string}, if (report?.reportID) { // This will be fixed as follow up https://github.com/Expensify/App/pull/75357 // eslint-disable-next-line @typescript-eslint/no-deprecated - return getReportName(getReport(report?.reportID, allReports)); + return getReportName({report: getReport(report?.reportID, allReports)}); } // This will be fixed as follow up https://github.com/Expensify/App/pull/75357 // eslint-disable-next-line @typescript-eslint/no-deprecated - return getReportName(report); + return getReportName({report}); } /** @@ -13280,4 +13269,5 @@ export type { SelfDMParameters, OptimisticReportAction, OptimisticAnnounceChat, + GetReportNameParams, }; diff --git a/src/libs/SearchQueryUtils.ts b/src/libs/SearchQueryUtils.ts index 9e143fbef6aae..4f186327a86c0 100644 --- a/src/libs/SearchQueryUtils.ts +++ b/src/libs/SearchQueryUtils.ts @@ -1142,7 +1142,7 @@ function getFilterDisplayValue( } if (filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.IN) { // eslint-disable-next-line @typescript-eslint/no-deprecated - return getReportName(reports?.[`${ONYXKEYS.COLLECTION.REPORT}${filterValue}`]) || filterValue; + return getReportName({report: reports?.[`${ONYXKEYS.COLLECTION.REPORT}${filterValue}`]}) || filterValue; } if (filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT || filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.TOTAL || filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.PURCHASE_AMOUNT) { const frontendAmount = convertToFrontendAmountAsInteger(Number(filterValue)); diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 50df8490b6dc2..685d163e3185b 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -1904,7 +1904,7 @@ function getTaskSections( const policy = data[`${ONYXKEYS.COLLECTION.POLICY}${parentReport.policyID}`]; const isParentReportArchived = archivedReportsIDList?.has(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${parentReport?.reportID}`); // eslint-disable-next-line @typescript-eslint/no-deprecated - const parentReportName = getReportName(parentReport, policy, undefined, undefined, undefined, undefined, undefined, isParentReportArchived); + const parentReportName = getReportName({report: parentReport, policy, isReportArchived: isParentReportArchived}); const icons = getIcons(parentReport, formatPhoneNumber, personalDetails, null, '', -1, policy, undefined, isParentReportArchived); const parentReportIcon = icons?.at(0); diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 4a75fbc26f665..fe57571fb4c57 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -406,7 +406,7 @@ function categorizeReportsForLHN( const reportID = report.reportID; // eslint-disable-next-line @typescript-eslint/no-deprecated - const displayName = getReportName(report, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, conciergeReportID); + const displayName = getReportName({report, conciergeReportID}); const miniReport: MiniReport = { reportID, displayName, @@ -884,7 +884,7 @@ function getOptionData({ const users = translate(targetAccountIDsLength > 1 ? 'common.members' : 'common.member')?.toLocaleLowerCase(); result.alternateText = formatReportLastMessageText(`${actorDisplayName ?? lastActorDisplayName}: ${verb} ${targetAccountIDsLength} ${users}`); // eslint-disable-next-line @typescript-eslint/no-deprecated - const roomName = getReportName(lastActionReport) || lastActionOriginalMessage?.roomName; + const roomName = getReportName({report: lastActionReport}) || lastActionOriginalMessage?.roomName; if (roomName) { const preposition = lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM || lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM @@ -1123,7 +1123,7 @@ function getOptionData({ } // eslint-disable-next-line @typescript-eslint/no-deprecated - const reportName = getReportName(report, policy, undefined, undefined, invoiceReceiverPolicy, undefined, undefined, isReportArchived, undefined, undefined, conciergeReportID); + const reportName = getReportName({report, policy, invoiceReceiverPolicy, isReportArchived, conciergeReportID}); result.text = reportName; result.subtitle = subtitle; @@ -1233,7 +1233,7 @@ function getRoomWelcomeMessage( const welcomeMessage: WelcomeMessage = {}; const workspaceName = getPolicyName({report}); // eslint-disable-next-line @typescript-eslint/no-deprecated - const reportName = getReportName(report); + const reportName = getReportName({report}); if (report?.description) { welcomeMessage.messageHtml = getReportDescription(report); diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index e00ba5ea1f241..a09a8e780dd6e 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -1013,7 +1013,7 @@ function getShareDestination( icons: ReportUtils.getIcons(report, LocalePhoneNumber.formatPhoneNumber, personalDetails, Expensicons.FallbackAvatar), // Will be fixed in https://github.com/Expensify/App/issues/76852 // eslint-disable-next-line @typescript-eslint/no-deprecated - displayName: ReportUtils.getReportName(report), + displayName: ReportUtils.getReportName({report}), subtitle, displayNamesWithTooltips, shouldUseFullTitleToDisplay: ReportUtils.shouldUseFullTitleToDisplay(report), diff --git a/src/pages/RoomInvitePage.tsx b/src/pages/RoomInvitePage.tsx index 731c3f872d36a..0bd917e9c99aa 100644 --- a/src/pages/RoomInvitePage.tsx +++ b/src/pages/RoomInvitePage.tsx @@ -200,7 +200,7 @@ function RoomInvitePage({ const backRoute = reportID && (!isPolicyEmployee || isReportArchived ? ROUTES.REPORT_WITH_ID_DETAILS.getRoute(reportID, backTo) : ROUTES.ROOM_MEMBERS.getRoute(reportID, backTo)); // eslint-disable-next-line @typescript-eslint/no-deprecated - const reportName = getReportName(report); + const reportName = getReportName({report}); const ancestors = useAncestors(report); diff --git a/src/pages/RoomMembersPage.tsx b/src/pages/RoomMembersPage.tsx index 6b44d3f311715..20e22c584d5bd 100644 --- a/src/pages/RoomMembersPage.tsx +++ b/src/pages/RoomMembersPage.tsx @@ -443,7 +443,7 @@ function RoomMembersPage({report, policy}: RoomMembersPageProps) { { if (isMobileSelectionModeEnabled) { setSelectedMembers([]); diff --git a/src/pages/ShareCodePage.tsx b/src/pages/ShareCodePage.tsx index 86e18454748a6..5b90d28523816 100644 --- a/src/pages/ShareCodePage.tsx +++ b/src/pages/ShareCodePage.tsx @@ -103,7 +103,7 @@ function ShareCodePage({report, policy, backTo}: ShareCodePageProps) { const reportForTitle = useMemo(() => getReportForHeader(report), [report]); // eslint-disable-next-line @typescript-eslint/no-deprecated - const title = isReport ? getReportName(reportForTitle) : (currentUserPersonalDetails.displayName ?? ''); + const title = isReport ? getReportName({report: reportForTitle}) : (currentUserPersonalDetails.displayName ?? ''); const urlWithTrailingSlash = addTrailingForwardSlash(environmentURL); const url = isReport ? `${urlWithTrailingSlash}${ROUTES.REPORT_WITH_ID.getRoute(report.reportID)}` diff --git a/src/pages/TripChatNameEditPage.tsx b/src/pages/TripChatNameEditPage.tsx index 44c86e47fdc0a..1c6d1111658ca 100644 --- a/src/pages/TripChatNameEditPage.tsx +++ b/src/pages/TripChatNameEditPage.tsx @@ -32,7 +32,7 @@ function TripChatNameEditPage({report}: TripChatNameEditPageProps) { const {inputCallbackRef} = useAutoFocusInput(); const reportID = report?.reportID; - const currentChatName = getReportName(report); + const currentChatName = getReportName({report}); const validate = (values: FormOnyxValues): Errors => { const errors: Errors = {}; diff --git a/src/pages/inbox/HeaderView.tsx b/src/pages/inbox/HeaderView.tsx index da7fb011d8634..76a4f4d9a9be4 100644 --- a/src/pages/inbox/HeaderView.tsx +++ b/src/pages/inbox/HeaderView.tsx @@ -152,7 +152,14 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked, const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); // Use sorted display names for the title for group chats on native small screen widths // eslint-disable-next-line @typescript-eslint/no-deprecated - const title = getReportName(reportHeaderData, policy, parentReportAction, personalDetails, invoiceReceiverPolicy, undefined, undefined, isReportHeaderDataArchived); + const title = getReportName({ + report: reportHeaderData, + policy, + parentReportActionParam: parentReportAction, + personalDetails, + invoiceReceiverPolicy, + isReportArchived: isReportHeaderDataArchived, + }); const subtitle = getChatRoomSubtitle(reportHeaderData, false, isReportHeaderDataArchived); // This is used to get the status badge for invoice report subtitle. const statusTextForInvoiceReport = isParentInvoiceAndIsChatThread diff --git a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx index 197a9000d680f..55fa2c9b6fadb 100644 --- a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx @@ -318,7 +318,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref const quickActionSubtitle = useMemo(() => { // eslint-disable-next-line @typescript-eslint/no-deprecated - return !hideQABSubtitle ? (getReportName(quickActionReport, quickActionPolicy, undefined, personalDetails) ?? translate('quickAction.updateDestination')) : ''; + return !hideQABSubtitle ? (getReportName({report: quickActionReport, policy: quickActionPolicy, personalDetails}) ?? translate('quickAction.updateDestination')) : ''; // eslint-disable-next-line react-hooks/exhaustive-deps }, [hideQABSubtitle, personalDetails, quickAction?.action, quickActionPolicy?.name, quickActionReport, translate]); @@ -534,7 +534,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref icon: icons.ReceiptScan, text: translate('quickAction.scanReceipt'), // eslint-disable-next-line @typescript-eslint/no-deprecated - description: getReportName(policyChatForActivePolicy), + description: getReportName({report: policyChatForActivePolicy}), shouldCallAfterModalHide: shouldUseNarrowLayout, onSelected, rightIconReportID: policyChatForActivePolicy?.reportID, diff --git a/src/pages/media/AttachmentModalScreen/routes/report/ReportAvatarModalContent.tsx b/src/pages/media/AttachmentModalScreen/routes/report/ReportAvatarModalContent.tsx index b008744803cab..3f9d459afb6a4 100644 --- a/src/pages/media/AttachmentModalScreen/routes/report/ReportAvatarModalContent.tsx +++ b/src/pages/media/AttachmentModalScreen/routes/report/ReportAvatarModalContent.tsx @@ -23,7 +23,7 @@ function ReportAvatarModalContent({navigation, route}: AttachmentModalScreenProp return { source: report?.avatarUrl ? getFullSizeAvatar({avatarSource: report.avatarUrl, defaultAvatars}) : getDefaultGroupAvatar(report?.reportID), // eslint-disable-next-line @typescript-eslint/no-deprecated - headerTitle: getReportName(report), + headerTitle: getReportName({report}), isWorkspaceAvatar: false, }; } @@ -31,7 +31,7 @@ function ReportAvatarModalContent({navigation, route}: AttachmentModalScreenProp return { source: getFullSizeAvatar({avatarSource: report.avatarUrl, defaultAvatars}), // eslint-disable-next-line @typescript-eslint/no-deprecated - headerTitle: getReportName(report), + headerTitle: getReportName({report}), isWorkspaceAvatar: false, }; } @@ -39,7 +39,7 @@ function ReportAvatarModalContent({navigation, route}: AttachmentModalScreenProp return { source: getFullSizeAvatar({avatarSource: report.avatarUrl, defaultAvatars}), // eslint-disable-next-line @typescript-eslint/no-deprecated - headerTitle: getReportName(report), + headerTitle: getReportName({report}), isWorkspaceAvatar: false, }; } diff --git a/tests/perf-test/ReportUtils.perf-test.ts b/tests/perf-test/ReportUtils.perf-test.ts index dd4d93f326f4f..30ac11a4a56ee 100644 --- a/tests/perf-test/ReportUtils.perf-test.ts +++ b/tests/perf-test/ReportUtils.perf-test.ts @@ -157,7 +157,7 @@ describe('ReportUtils', () => { await waitForBatchedUpdates(); // Will be fixed in https://github.com/Expensify/App/issues/76852 // eslint-disable-next-line @typescript-eslint/no-deprecated - await measureFunction(() => getReportName(report, policy)); + await measureFunction(() => getReportName({report, policy})); }); test('[ReportUtils] canShowReportRecipientLocalTime on 1k participants', async () => { diff --git a/tests/ui/MoneyRequestReportPreview.test.tsx b/tests/ui/MoneyRequestReportPreview.test.tsx index 7e5c1b8e61b75..2dd47f91e5f7e 100644 --- a/tests/ui/MoneyRequestReportPreview.test.tsx +++ b/tests/ui/MoneyRequestReportPreview.test.tsx @@ -158,7 +158,7 @@ describe('MoneyRequestReportPreview', () => { // This will be fixed as follow up https://github.com/Expensify/App/pull/75357 // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getByText(ReportUtils.getReportName(mockIOUReport, undefined, undefined, undefined, undefined, undefined))).toBeOnTheScreen(); + expect(screen.getByText(ReportUtils.getReportName({report: mockIOUReport}))).toBeOnTheScreen(); for (const transaction of arrayOfTransactions) { const {transactionDisplayAmount, transactionHeaderText} = getTransactionDisplayAmountAndHeaderText(transaction); diff --git a/tests/unit/ModifiedExpenseMessageTest.ts b/tests/unit/ModifiedExpenseMessageTest.ts index 32bddfe237fd1..d79510ca50ddc 100644 --- a/tests/unit/ModifiedExpenseMessageTest.ts +++ b/tests/unit/ModifiedExpenseMessageTest.ts @@ -33,7 +33,7 @@ describe('ModifiedExpenseMessage', () => { beforeEach(() => { // The `getReportName` method is quite complex, and we don't need to test it here - jest.spyOn(ReportUtils, 'getReportName').mockImplementation((report) => report?.reportName ?? ''); + jest.spyOn(ReportUtils, 'getReportName').mockImplementation((reportNameInformation) => reportNameInformation?.report?.reportName ?? ''); }); afterEach(() => { diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index a85b906cd66aa..64eddd2762eec 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -1446,7 +1446,7 @@ describe('ReportUtils', () => { } as ReportAction; // eslint-disable-next-line @typescript-eslint/no-deprecated - const reportName = getReportNameDeprecated(transactionThread, undefined, unreportedTransactionAction); + const reportName = getReportNameDeprecated({report: transactionThread, parentReportActionParam: unreportedTransactionAction}); // Should NOT contain HTML tags expect(reportName).not.toContain(' { }; // eslint-disable-next-line @typescript-eslint/no-deprecated - const reportName = getReportNameDeprecated(report, policy, undefined, participantsPersonalDetails, undefined, undefined, [], false, [], [], explicitConciergeReportID); + const reportName = getReportNameDeprecated({ + report, + policy, + personalDetails: participantsPersonalDetails, + transactions: [], + isReportArchived: false, + reports: [], + policies: [], + conciergeReportID: explicitConciergeReportID, + }); expect(reportName).toBe(CONST.CONCIERGE_DISPLAY_NAME); }); @@ -1663,7 +1672,16 @@ describe('ReportUtils', () => { }; // eslint-disable-next-line @typescript-eslint/no-deprecated - const reportName = getReportNameDeprecated(report, policy, undefined, participantsPersonalDetails, undefined, undefined, [], false, [], [], explicitConciergeReportID); + const reportName = getReportNameDeprecated({ + report, + policy, + personalDetails: participantsPersonalDetails, + transactions: [], + isReportArchived: false, + reports: [], + policies: [], + conciergeReportID: explicitConciergeReportID, + }); expect(reportName).not.toBe(CONST.CONCIERGE_DISPLAY_NAME); // Should generate name from participants instead expect(reportName).toBe('Ragnar Lothbrok'); @@ -1677,7 +1695,7 @@ describe('ReportUtils', () => { }; // eslint-disable-next-line @typescript-eslint/no-deprecated - const reportName = getReportNameDeprecated(report, policy, undefined, participantsPersonalDetails); + const reportName = getReportNameDeprecated({report, policy, personalDetails: participantsPersonalDetails}); expect(reportName).toBe(CONST.CONCIERGE_DISPLAY_NAME); }); }); From 36f3ec53dd5137fa211dd599842bfd79b50bc087 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 23 Feb 2026 15:19:39 +0700 Subject: [PATCH 2/3] update test --- src/pages/TripChatNameEditPage.tsx | 1 + tests/unit/Search/buildSubstitutionsMapTest.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/TripChatNameEditPage.tsx b/src/pages/TripChatNameEditPage.tsx index 1c6d1111658ca..de2e01c353fd4 100644 --- a/src/pages/TripChatNameEditPage.tsx +++ b/src/pages/TripChatNameEditPage.tsx @@ -32,6 +32,7 @@ function TripChatNameEditPage({report}: TripChatNameEditPageProps) { const {inputCallbackRef} = useAutoFocusInput(); const reportID = report?.reportID; + // eslint-disable-next-line @typescript-eslint/no-deprecated const currentChatName = getReportName({report}); const validate = (values: FormOnyxValues): Errors => { diff --git a/tests/unit/Search/buildSubstitutionsMapTest.ts b/tests/unit/Search/buildSubstitutionsMapTest.ts index e5e23a02c7594..48be9c25ba51d 100644 --- a/tests/unit/Search/buildSubstitutionsMapTest.ts +++ b/tests/unit/Search/buildSubstitutionsMapTest.ts @@ -11,8 +11,8 @@ jest.mock('@libs/ReportUtils', () => { return { parseReportRouteParams: jest.fn(() => ({})), // The `getReportName` method is quite complex, and we don't need to test it, we just want to test the logic around generating substitutionsMap - getReportName(report: OnyxTypes.Report) { - return report.reportName; + getReportName(reportNameInformation: {report: OnyxTypes.Report}) { + return reportNameInformation.report?.reportName; }, }; }); From 0eab26c21dcedef659e76465b2a1dfaab7ea05e5 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 26 Feb 2026 09:58:11 +0700 Subject: [PATCH 3/3] add comment --- src/libs/ReportUtils.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 2112ce525b16d..0525c21634cf9 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -942,11 +942,14 @@ type GetReportNameParams = { parentReportActionParam?: OnyxInputOrEntry; personalDetails?: Partial; invoiceReceiverPolicy?: OnyxEntry; + /** Report attributes used to return a precomputed report name */ reportAttributes?: ReportAttributesDerivedValue['reports']; transactions?: Transaction[]; reports?: Report[]; policies?: Policy[]; isReportArchived?: boolean; + // TODO: Make this required when https://github.com/Expensify/App/issues/66411 is done + /** Used to identify the Concierge chat so its name can be set to the Concierge display name */ conciergeReportID?: string; };