diff --git a/src/components/AvatarWithDisplayName.tsx b/src/components/AvatarWithDisplayName.tsx index c39a7c2244c8d..2c308c8b7ba80 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 de29513e46706..17e402d64dbdd 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -826,7 +826,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 6fb2bd04d88aa..8c34bfea6cc54 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 6363790747cd4..3df24270115a4 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 7ee5e84c9d42b..a329c1db61dee 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1941,7 +1941,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 b4dbce6adc138..0f5017d849224 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -945,10 +945,15 @@ 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; }; type GetReportStatusParams = { @@ -5614,7 +5619,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])}) ?? ''; } } @@ -5706,20 +5711,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; @@ -5753,7 +5747,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); } @@ -5934,18 +5928,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 @@ -5956,18 +5949,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, + }); } /** @@ -6110,7 +6102,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}), }; } @@ -6857,7 +6849,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 = Parser.htmlToText(getReportName(report) ?? report?.reportName ?? ''); + const reportName = Parser.htmlToText(getReportName({report}) ?? report?.reportName ?? ''); const reportUrl = getReportURLForCurrentContext(report?.reportID); if (typeof fromReportID === 'undefined') { return translate('iou.movedTransactionTo', reportUrl, reportName); @@ -6873,7 +6865,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 = Parser.htmlToText(getReportName(fromReport) ?? fromReport?.reportName ?? ''); + const reportName = Parser.htmlToText(getReportName({report: fromReport}) ?? fromReport?.reportName ?? ''); let reportUrl = getReportURLForCurrentContext(fromReportID); @@ -12514,12 +12506,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}); } /** @@ -13338,4 +13330,5 @@ export type { SelfDMParameters, OptimisticReportAction, OptimisticAnnounceChat, + GetReportNameParams, }; diff --git a/src/libs/SearchQueryUtils.ts b/src/libs/SearchQueryUtils.ts index f6762c0cabfa5..12a769a296204 100644 --- a/src/libs/SearchQueryUtils.ts +++ b/src/libs/SearchQueryUtils.ts @@ -1155,7 +1155,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 279afb5fb651f..a8f4558eb6cd0 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -1992,7 +1992,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 0be9cefa99dfc..ad84fb4805acb 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -420,7 +420,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, @@ -880,7 +880,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 @@ -1127,7 +1127,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; @@ -1237,7 +1237,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 8ad3e1d732a9d..adc7e247fe16d 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 e99c47b5e9a75..b1fe9eddb4c5b 100644 --- a/src/pages/RoomMembersPage.tsx +++ b/src/pages/RoomMembersPage.tsx @@ -441,7 +441,7 @@ function RoomMembersPage({report, policy}: RoomMembersPageProps) { { if (isMobileSelectionModeEnabled) { setSelectedMembers([]); diff --git a/src/pages/ShareCodePage.tsx b/src/pages/ShareCodePage.tsx index d0d2428eb162e..b3a3ca80f63f8 100644 --- a/src/pages/ShareCodePage.tsx +++ b/src/pages/ShareCodePage.tsx @@ -101,7 +101,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..de2e01c353fd4 100644 --- a/src/pages/TripChatNameEditPage.tsx +++ b/src/pages/TripChatNameEditPage.tsx @@ -32,7 +32,8 @@ function TripChatNameEditPage({report}: TripChatNameEditPageProps) { const {inputCallbackRef} = useAutoFocusInput(); const reportID = report?.reportID; - const currentChatName = getReportName(report); + // eslint-disable-next-line @typescript-eslint/no-deprecated + const currentChatName = getReportName({report}); const validate = (values: FormOnyxValues): Errors => { const errors: Errors = {}; diff --git a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx index 7c061995558fd..e91245da4ed14 100644 --- a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx @@ -313,7 +313,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]); @@ -529,7 +529,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 31c709a971aec..4c4a5fc47b476 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 01c7a0067d763..8f097130c52e8 100644 --- a/tests/ui/MoneyRequestReportPreview.test.tsx +++ b/tests/ui/MoneyRequestReportPreview.test.tsx @@ -155,7 +155,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 071e3c90a7c91..e29971f97c932 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -1453,7 +1453,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); }); @@ -1670,7 +1679,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'); @@ -1684,7 +1702,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); }); }); 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; }, }; });