From 94eb0975b0537a80bdf1588c12f4e0cb84322993 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sat, 17 Jan 2026 23:36:13 +0800 Subject: [PATCH 1/7] fix different invoice report name in report preview --- .../MoneyRequestReportPreviewContent.tsx | 11 +- src/libs/ReportUtils.ts | 12 -- tests/unit/ReportUtilsTest.ts | 141 ------------------ 3 files changed, 2 insertions(+), 162 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 504981d3488f2..666508884a0dd 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -44,13 +44,12 @@ import Navigation from '@libs/Navigation/Navigation'; import Performance from '@libs/Performance'; import {getConnectedIntegration, hasDynamicExternalWorkflow} from '@libs/PolicyUtils'; import {hasPendingDEWSubmit} from '@libs/ReportActionsUtils'; -import {getInvoicePayerName} from '@libs/ReportNameUtils'; +import {getInvoicePayerName, getReportName} from '@libs/ReportNameUtils'; import getReportPreviewAction from '@libs/ReportPreviewActionUtils'; import { areAllRequestsBeingSmartScanned as areAllRequestsBeingSmartScannedReportUtils, getAddExpenseDropdownOptions, getDisplayNameForParticipant, - getMoneyReportPreviewName, getMoneyRequestSpendBreakdown, getNonHeldAndFullAmount, getPolicyName, @@ -218,12 +217,6 @@ function MoneyRequestReportPreviewContent({ const [reportAttributes] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: reportAttributesSelector}); - const currentReportName = iouReport?.reportID ? reportAttributes?.[iouReport.reportID]?.reportName : undefined; - const reportPreviewName = useMemo(() => { - return getMoneyReportPreviewName(action, iouReport, isInvoice, reportAttributes); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [action, iouReport, isInvoice, currentReportName]); - const hasReceipts = transactionsWithReceipts.length > 0; const isScanning = hasReceipts && areAllRequestsBeingSmartScanned; const existingB2BInvoiceReport = useParticipantsInvoiceReport(activePolicyID, CONST.REPORT.INVOICE_RECEIVER_TYPE.BUSINESS, chatReport?.policyID); @@ -737,7 +730,7 @@ function MoneyRequestReportPreviewContent({ style={[styles.headerText]} testID="MoneyRequestReportPreview-reportName" > - {reportPreviewName} + {getReportName(iouReport, reportAttributes)} diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 346b98baba3ae..0b64fb7051910 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -12646,17 +12646,6 @@ function hasReportBeenRetracted(report: OnyxEntry, reportActions?: OnyxE return reportActionList.some((action) => isRetractedAction(action)); } -function getMoneyReportPreviewName(action: ReportAction, iouReport: OnyxEntry, isInvoice?: boolean, reportAttributes?: ReportAttributesDerivedValue['reports']) { - if (isInvoice && isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW)) { - const originalMessage = getOriginalMessage(action); - // eslint-disable-next-line @typescript-eslint/no-deprecated - return originalMessage && translateLocal('iou.invoiceReportName', originalMessage); - } - // This will be fixed as follow up https://github.com/Expensify/App/pull/75357 - // eslint-disable-next-line @typescript-eslint/no-deprecated - return getReportName(iouReport, undefined, undefined, undefined, undefined, reportAttributes) || action.childReportName; -} - function selectFilteredReportActions( reportActions: Record> | undefined> | null | undefined, ): Record | undefined { @@ -13299,7 +13288,6 @@ export { canRejectReportAction, hasReportBeenReopened, hasReportBeenRetracted, - getMoneyReportPreviewName, getNextApproverAccountID, isWorkspaceTaskReport, isWorkspaceThread, diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index 6f927e6f12706..6facd1d9fbefa 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -68,7 +68,6 @@ import { getIconsForParticipants, getIndicatedMissingPaymentMethod, getIOUReportActionDisplayMessage, - getMoneyReportPreviewName, getMostRecentlyVisitedReport, getOutstandingChildRequest, getParentNavigationSubtitle, @@ -6056,146 +6055,6 @@ describe('ReportUtils', () => { }); }); - describe('getMoneyReportPreviewName', () => { - beforeAll(async () => { - await Onyx.clear(); - await Onyx.multiSet({ - [ONYXKEYS.PERSONAL_DETAILS_LIST]: participantsPersonalDetails, - [ONYXKEYS.SESSION]: {email: currentUserEmail, accountID: currentUserAccountID}, - }); - }); - - afterAll(async () => { - await Onyx.clear(); - }); - - it('should return the report name when the chat type is policy room', () => { - const action: ReportAction = { - ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW, - }; - const report: Report = createRandomReport(1, CONST.REPORT.CHAT_TYPE.POLICY_ROOM); - const result = getMoneyReportPreviewName(action, report); - expect(result).toBe(report.reportName); - }); - - it('should return the report name when the chat type is domain all', () => { - const action: ReportAction = { - ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW, - }; - const report: Report = createRandomReport(1, CONST.REPORT.CHAT_TYPE.DOMAIN_ALL); - const result = getMoneyReportPreviewName(action, report); - expect(result).toBe(report.reportName); - }); - - it('should return the report name when the chat type is group', () => { - const action: ReportAction = { - ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW, - }; - const report: Report = createRandomReport(1, CONST.REPORT.CHAT_TYPE.GROUP); - const result = getMoneyReportPreviewName(action, report); - expect(result).toBe(report.reportName); - }); - - it('should return policy name when the chat type is invoice', () => { - const action: ReportAction = { - ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW, - }; - const report: Report = createRandomReport(1, CONST.REPORT.CHAT_TYPE.INVOICE); - const result = getMoneyReportPreviewName(action, report); - // Policies are empty, so the policy name is "Unavailable workspace" - expect(result).toBe('Unavailable workspace'); - }); - - it('should return the report name when the chat type is policy admins', () => { - const action: ReportAction = { - ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW, - }; - const report: Report = createRandomReport(1, CONST.REPORT.CHAT_TYPE.POLICY_ADMINS); - const result = getMoneyReportPreviewName(action, report); - expect(result).toBe(report.reportName); - }); - - it('should return the report name when the chat type is policy announce', () => { - const action: ReportAction = { - ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW, - }; - const report: Report = createRandomReport(1, CONST.REPORT.CHAT_TYPE.POLICY_ANNOUNCE); - const result = getMoneyReportPreviewName(action, report); - expect(result).toBe(report.reportName); - }); - - it('should return the owner name expenses when the chat type is policy expense chat', () => { - const action: ReportAction = { - ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW, - }; - const report: Report = createRandomReport(1, CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); - const result = getMoneyReportPreviewName(action, report); - // Report with ownerAccountID: 1 corresponds to "Ragnar Lothbrok" - expect(result).toBe("Ragnar Lothbrok's expenses"); - }); - - it('should return the display name of the current user when the chat type is self dm', () => { - const action: ReportAction = { - ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW, - }; - const report: Report = createRandomReport(1, CONST.REPORT.CHAT_TYPE.SELF_DM); - const result = getMoneyReportPreviewName(action, report); - // currentUserAccountID: 5 corresponds to "Lagertha Lothbrok" - expect(result).toBe('Lagertha Lothbrok (you)'); - }); - - it('should return the participant name when the chat type is system', () => { - const action: ReportAction = { - ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW, - }; - const report: Report = { - ...createRandomReport(1, CONST.REPORT.CHAT_TYPE.SYSTEM), - participants: { - 1: {notificationPreference: 'hidden'}, - }, - }; - const result = getMoneyReportPreviewName(action, report); - // participant accountID: 1 corresponds to "Ragnar Lothbrok" - expect(result).toBe('Ragnar Lothbrok'); - }); - - it('should return the participant names when the chat type is trip room', () => { - const action: ReportAction = { - ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW, - }; - const report: Report = { - ...createRandomReport(1, CONST.REPORT.CHAT_TYPE.TRIP_ROOM), - participants: { - 1: {notificationPreference: 'hidden'}, - 2: {notificationPreference: 'always'}, - }, - }; - const result = getMoneyReportPreviewName(action, report); - // participant accountID: 1, 2 corresponds to "Ragnar", "floki@vikings.net" - expect(result).toBe('Ragnar, floki@vikings.net'); - }); - - it('should return the child report name when the report name is not present', () => { - const action: ReportAction = { - ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW, - childReportName: 'Child Report', - }; - const result = getMoneyReportPreviewName(action, undefined); - expect(result).toBe('Child Report'); - }); - }); - describe('canAddTransaction', () => { it('should return true for a non-archived report', async () => { // Given a non-archived expense report From 50872ca7dc98dd933af4458b8833e81a8071e602 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sun, 18 Jan 2026 00:20:33 +0800 Subject: [PATCH 2/7] lint --- .../MoneyRequestReportPreviewContent.tsx | 1 - .../ReportActionItem/MoneyRequestReportPreview/index.tsx | 2 -- .../ReportActionItem/MoneyRequestReportPreview/types.ts | 3 --- src/pages/home/report/PureReportActionItem.tsx | 1 - 4 files changed, 7 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 666508884a0dd..ad7c7efcb62fe 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -117,7 +117,6 @@ function MoneyRequestReportPreviewContent({ currentWidth, reportPreviewStyles, shouldDisplayContextMenu = true, - isInvoice, shouldShowBorder = false, onPress, forwardedFSClass, diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx index 957cc1db45f86..c1905671b38d9 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx @@ -36,7 +36,6 @@ function MoneyRequestReportPreview({ onPaymentOptionsShow, onPaymentOptionsHide, shouldDisplayContextMenu = true, - isInvoice = false, shouldShowBorder, }: MoneyRequestReportPreviewProps) { const styles = useThemeStyles(); @@ -168,7 +167,6 @@ function MoneyRequestReportPreview({ currentWidth={widths.currentWidth} reportPreviewStyles={reportPreviewStyles} shouldDisplayContextMenu={shouldDisplayContextMenu} - isInvoice={isInvoice} onPress={openReportFromPreview} shouldShowBorder={shouldShowBorder} forwardedFSClass={CONST.FULLSTORY.CLASS.UNMASK} diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/types.ts b/src/components/ReportActionItem/MoneyRequestReportPreview/types.ts index 0fb20456c25c9..d8b5a8d464e25 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/types.ts +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/types.ts @@ -63,9 +63,6 @@ type MoneyRequestReportPreviewProps = { /** Whether context menu should be shown on press */ shouldDisplayContextMenu?: boolean; - /** Whether the report is an invoice preview */ - isInvoice?: boolean; - /** Whether to show a border to separate Reports Chat Item and Money Request Report Preview */ shouldShowBorder?: boolean; }; diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index b519ce5d0f59c..da96c57724f36 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -1175,7 +1175,6 @@ function PureReportActionItem({ contextMenuAnchor={popoverAnchorRef.current} isHovered={hovered} isWhisper={isWhisper} - isInvoice={action.childType === CONST.REPORT.CHAT_TYPE.INVOICE} checkIfContextMenuActive={toggleContextMenuFromActiveReportAction} onPaymentOptionsShow={() => setIsPaymentMethodPopoverActive(true)} onPaymentOptionsHide={() => setIsPaymentMethodPopoverActive(false)} From a51aa645e961bd16fc9a8b0bbf025b17038d08ed Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sun, 18 Jan 2026 18:28:01 +0800 Subject: [PATCH 3/7] use deprecated func to avoid regression --- .../MoneyRequestReportPreviewContent.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index ad7c7efcb62fe..5b219013547eb 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -44,7 +44,7 @@ import Navigation from '@libs/Navigation/Navigation'; import Performance from '@libs/Performance'; import {getConnectedIntegration, hasDynamicExternalWorkflow} from '@libs/PolicyUtils'; import {hasPendingDEWSubmit} from '@libs/ReportActionsUtils'; -import {getInvoicePayerName, getReportName} from '@libs/ReportNameUtils'; +import {getInvoicePayerName} from '@libs/ReportNameUtils'; import getReportPreviewAction from '@libs/ReportPreviewActionUtils'; import { areAllRequestsBeingSmartScanned as areAllRequestsBeingSmartScannedReportUtils, @@ -53,6 +53,7 @@ import { getMoneyRequestSpendBreakdown, getNonHeldAndFullAmount, getPolicyName, + getReportName, getReportStatusColorStyle, getReportStatusTranslation, getTransactionsWithReceipts, @@ -729,7 +730,7 @@ function MoneyRequestReportPreviewContent({ style={[styles.headerText]} testID="MoneyRequestReportPreview-reportName" > - {getReportName(iouReport, reportAttributes)} + {getReportName(iouReport, undefined, undefined, undefined, undefined, reportAttributes)} From 084d3a0b10b9651857ea28a017dd69ede5d0ebaa Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sun, 18 Jan 2026 18:49:47 +0800 Subject: [PATCH 4/7] suppress lint --- .../MoneyRequestReportPreviewContent.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 5b219013547eb..00eb4229afaeb 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -730,6 +730,8 @@ function MoneyRequestReportPreviewContent({ style={[styles.headerText]} testID="MoneyRequestReportPreview-reportName" > + {/* 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)} From 9de362ac49d29e62d8ae8b95dfa843873532950b Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sun, 18 Jan 2026 20:28:04 +0800 Subject: [PATCH 5/7] update test --- tests/ui/MoneyRequestReportPreview.test.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/ui/MoneyRequestReportPreview.test.tsx b/tests/ui/MoneyRequestReportPreview.test.tsx index e2c9624fc5a8a..8a1b36926f99b 100644 --- a/tests/ui/MoneyRequestReportPreview.test.tsx +++ b/tests/ui/MoneyRequestReportPreview.test.tsx @@ -39,7 +39,7 @@ jest.mock('@rnmapbox/maps', () => { jest.mock('@src/hooks/useReportWithTransactionsAndViolations', () => jest.fn((): [OnyxEntry, Transaction[], OnyxCollection] => { - return [mockChatReport, [mockTransaction, {...mockTransaction, transactionID: mockSecondTransactionID}], {violations: mockViolations}]; + return [mockIOUReport, [mockTransaction, {...mockTransaction, transactionID: mockSecondTransactionID}], {violations: mockViolations}]; }), ); @@ -155,11 +155,12 @@ describe('MoneyRequestReportPreview', () => { await waitForBatchedUpdatesWithAct(); }); await waitForBatchedUpdatesWithAct(); - const {reportName: moneyRequestReportPreviewName = ''} = mockChatReport; + + expect(screen.getByText(ReportUtils.getReportName(mockIOUReport, undefined, undefined, undefined, undefined, undefined))).toBeOnTheScreen(); + for (const transaction of arrayOfTransactions) { const {transactionDisplayAmount, transactionHeaderText} = getTransactionDisplayAmountAndHeaderText(transaction); - expect(screen.getByText(moneyRequestReportPreviewName)).toBeOnTheScreen(); expect(screen.getByText(transactionDisplayAmount)).toBeOnTheScreen(); expect(screen.getAllByText(transactionHeaderText)).toHaveLength(arrayOfTransactions.length); expect(screen.getAllByText(transaction.merchant)).toHaveLength(arrayOfTransactions.length); From c0aaec4512a5853271bc147fd656c96be2314da2 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 19 Jan 2026 10:18:04 +0800 Subject: [PATCH 6/7] supress lint --- tests/ui/MoneyRequestReportPreview.test.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/ui/MoneyRequestReportPreview.test.tsx b/tests/ui/MoneyRequestReportPreview.test.tsx index 8a1b36926f99b..7e5c1b8e61b75 100644 --- a/tests/ui/MoneyRequestReportPreview.test.tsx +++ b/tests/ui/MoneyRequestReportPreview.test.tsx @@ -156,6 +156,8 @@ describe('MoneyRequestReportPreview', () => { }); await waitForBatchedUpdatesWithAct(); + // 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(); for (const transaction of arrayOfTransactions) { From 32d868ad1a09d3f575a99b7da919aaa358911ef7 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 21 Jan 2026 10:37:00 +0800 Subject: [PATCH 7/7] fallback to child report name --- .../MoneyRequestReportPreviewContent.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 00eb4229afaeb..7354e043984d5 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -732,7 +732,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)} + {getReportName(iouReport, undefined, undefined, undefined, undefined, reportAttributes) || action.childReportName}