From 44b99ca27a83ac4fdda91aa6ae7d5b5ae47fdbdc Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Sun, 3 May 2026 19:40:50 +0530 Subject: [PATCH 1/3] Refactor: isolate getCombinedReportActions from ONYXKEYS.COLLECTION.REPORT Onyx data --- src/libs/OptionsListUtils/index.ts | 2 +- src/libs/ReportActionsUtils.ts | 3 +-- src/libs/actions/OnyxDerived/configs/sortedReportActions.ts | 2 +- .../inbox/report/ReportActionCompose/useLastEditableAction.ts | 2 +- src/pages/inbox/report/ReportActionsView.tsx | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index f94b4806521a..5e159f586a15 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -266,7 +266,7 @@ Onyx.connect({ if (transactionThreadReportID) { const transactionThreadReportActionsArray = Object.values(actions[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`] ?? {}); - sortedReportActions = getCombinedReportActions(sortedReportActions, transactionThreadReportID, transactionThreadReportActionsArray, reportID); + sortedReportActions = getCombinedReportActions(sortedReportActions, transactionThreadReportID, transactionThreadReportActionsArray, report); } const firstReportAction = sortedReportActions.at(0); diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index ea6c8d9b27ea..735e3f14b79c 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -773,7 +773,7 @@ function getCombinedReportActions( reportActions: ReportAction[], transactionThreadReportID: string | null, transactionThreadReportActions: ReportAction[], - reportID?: string, + report: OnyxEntry, ): ReportAction[] { const isSentMoneyReport = reportActions.some((action) => isSentMoneyReportAction(action)); @@ -797,7 +797,6 @@ function getCombinedReportActions( filteredParentReportActions = reportActions?.filter((action) => action.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED); } - const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; const isSelfDM = report?.chatType === CONST.REPORT.CHAT_TYPE.SELF_DM; // Filter out request and send money request actions because we don't want to show any preview actions for one transaction reports const filteredReportActions = [...filteredParentReportActions, ...filteredTransactionThreadReportActions].filter((action) => { diff --git a/src/libs/actions/OnyxDerived/configs/sortedReportActions.ts b/src/libs/actions/OnyxDerived/configs/sortedReportActions.ts index 8288692e602e..b1da171d04ea 100644 --- a/src/libs/actions/OnyxDerived/configs/sortedReportActions.ts +++ b/src/libs/actions/OnyxDerived/configs/sortedReportActions.ts @@ -23,7 +23,7 @@ function computeForReport( if (transactionThreadReportID && allReportActions) { const transactionThreadReportActionsArray = Object.values(allReportActions[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`] ?? {}); - sortedReportActions = getCombinedReportActions(sortedReportActions, transactionThreadReportID, transactionThreadReportActionsArray, reportID); + sortedReportActions = getCombinedReportActions(sortedReportActions, transactionThreadReportID, transactionThreadReportActionsArray, report); } return { diff --git a/src/pages/inbox/report/ReportActionCompose/useLastEditableAction.ts b/src/pages/inbox/report/ReportActionCompose/useLastEditableAction.ts index 09e125d898b6..c0a146904be9 100644 --- a/src/pages/inbox/report/ReportActionCompose/useLastEditableAction.ts +++ b/src/pages/inbox/report/ReportActionCompose/useLastEditableAction.ts @@ -33,7 +33,7 @@ function useLastEditableAction(reportID: string): OnyxEntry (reportActionsToDisplay ? getCombinedReportActions(reportActionsToDisplay, transactionThreadReportID ?? null, transactionThreadReportActions ?? []) : []), + () => (reportActionsToDisplay ? getCombinedReportActions(reportActionsToDisplay, transactionThreadReportID ?? null, transactionThreadReportActions ?? [], undefined) : []), [reportActionsToDisplay, transactionThreadReportActions, transactionThreadReportID], ); From 11aef2e3dbc9b5d6b026db832dcf0477e8ca1f13 Mon Sep 17 00:00:00 2001 From: "Shubham Agrawal (via MelvinBot)" Date: Wed, 6 May 2026 12:53:19 +0000 Subject: [PATCH 2/3] Add unit tests for getCombinedReportActions Tests cover: - Returns original actions when transactionThreadReportID is null - Returns original actions for sent money reports - Combines and sorts actions from parent and transaction thread - CREATED action deduplication logic - IOU CREATE/TRACK filtering in non-selfDM context - IOU TRACK kept in selfDM context - Report parameter correctly determines selfDM behavior Co-authored-by: Shubham Agrawal --- tests/unit/ReportActionsUtilsTest.ts | 116 +++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index bb53b2a8a2d7..fc117b093342 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -19,6 +19,7 @@ import { getAutoPayApprovedReportsEnabledMessage, getAutoReimbursementMessage, getCardIssuedMessage, + getCombinedReportActions, getCompanyAddressUpdateMessage, getCreatedReportForUnapprovedTransactionsMessage, getCurrencyDefaultTaxUpdateMessage, @@ -5226,4 +5227,119 @@ describe('ReportActionsUtils', () => { expect(getHumanAgentFirstName(action, makePersonalDetails(' '))).toBeUndefined(); }); }); + + describe('getCombinedReportActions', () => { + const makeAction = (id: string, actionName: string, created: string, overrides: Partial = {}): ReportAction => + ({ + reportActionID: id, + actionName, + created, + message: [{type: 'TEXT', html: '', text: '', isEdited: false, isDeletedParentAction: false}], + ...overrides, + }) as unknown as ReportAction; + + const makeIOUAction = (id: string, created: string, type: string, hasIOUDetails = false): ReportAction => + makeAction(id, CONST.REPORT.ACTIONS.TYPE.IOU, created, { + originalMessage: { + type, + ...(hasIOUDetails ? {IOUDetails: {amount: 100, currency: 'USD'}} : {}), + }, + } as Partial); + + it('returns original reportActions when transactionThreadReportID is null', () => { + const actions = [makeAction('1', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 10:00:00')]; + const result = getCombinedReportActions(actions, null, [], undefined); + expect(result).toEqual(actions); + }); + + it('returns original reportActions for sent money reports', () => { + const sentMoneyAction = makeIOUAction('1', '2024-01-01 10:00:00', CONST.IOU.REPORT_ACTION_TYPE.PAY, true); + const actions = [sentMoneyAction]; + const result = getCombinedReportActions(actions, 'txnThread1', [makeAction('2', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 11:00:00')], undefined); + expect(result).toEqual(actions); + }); + + it('combines and sorts actions from parent and transaction thread', () => { + const parentCreated = makeAction('1', CONST.REPORT.ACTIONS.TYPE.CREATED, '2024-01-01 08:00:00'); + const parentComment = makeAction('2', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 10:00:00'); + const txnComment = makeAction('3', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 09:00:00'); + const txnCreated = makeAction('4', CONST.REPORT.ACTIONS.TYPE.CREATED, '2024-01-01 09:30:00'); + + const result = getCombinedReportActions([parentCreated, parentComment], 'txnThread1', [txnCreated, txnComment], undefined); + + // parentCreated should be kept since it's older; txnCreated should be filtered out + // Result should be sorted descending by created, with CREATED last + const resultIDs = result.map((a) => a.reportActionID); + expect(resultIDs).toContain('1'); + expect(resultIDs).toContain('2'); + expect(resultIDs).toContain('3'); + }); + + it('keeps transaction thread CREATED when it is older than parent CREATED', () => { + const parentCreated = makeAction('1', CONST.REPORT.ACTIONS.TYPE.CREATED, '2024-01-01 10:00:00'); + const txnCreated = makeAction('2', CONST.REPORT.ACTIONS.TYPE.CREATED, '2024-01-01 08:00:00'); + + const result = getCombinedReportActions([parentCreated], 'txnThread1', [txnCreated], undefined); + const actionNames = result.map((a) => a.actionName); + // Only one CREATED should be present + expect(actionNames.filter((name) => name === CONST.REPORT.ACTIONS.TYPE.CREATED).length).toBe(1); + }); + + it('filters out IOU CREATE actions in non-selfDM context', () => { + const parentCreated = makeAction('1', CONST.REPORT.ACTIONS.TYPE.CREATED, '2024-01-01 08:00:00'); + const iouCreateAction = makeIOUAction('2', '2024-01-01 09:00:00', CONST.IOU.REPORT_ACTION_TYPE.CREATE); + const txnComment = makeAction('3', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 10:00:00'); + + const result = getCombinedReportActions([parentCreated, iouCreateAction], 'txnThread1', [txnComment], undefined); + const resultIDs = result.map((a) => a.reportActionID); + expect(resultIDs).not.toContain('2'); + }); + + it('filters out IOU TRACK actions in non-selfDM context', () => { + const parentCreated = makeAction('1', CONST.REPORT.ACTIONS.TYPE.CREATED, '2024-01-01 08:00:00'); + const iouTrackAction = makeIOUAction('2', '2024-01-01 09:00:00', CONST.IOU.REPORT_ACTION_TYPE.TRACK); + const txnComment = makeAction('3', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 10:00:00'); + + const result = getCombinedReportActions([parentCreated, iouTrackAction], 'txnThread1', [txnComment], undefined); + const resultIDs = result.map((a) => a.reportActionID); + expect(resultIDs).not.toContain('2'); + }); + + it('keeps IOU TRACK actions in selfDM context', () => { + const parentCreated = makeAction('1', CONST.REPORT.ACTIONS.TYPE.CREATED, '2024-01-01 08:00:00'); + const iouTrackAction = makeIOUAction('2', '2024-01-01 09:00:00', CONST.IOU.REPORT_ACTION_TYPE.TRACK); + const txnComment = makeAction('3', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 10:00:00'); + const selfDMReport = {chatType: CONST.REPORT.CHAT_TYPE.SELF_DM} as Report; + + const result = getCombinedReportActions([parentCreated, iouTrackAction], 'txnThread1', [txnComment], selfDMReport); + const resultIDs = result.map((a) => a.reportActionID); + expect(resultIDs).toContain('2'); + }); + + it('filters out IOU CREATE actions even in selfDM context', () => { + const parentCreated = makeAction('1', CONST.REPORT.ACTIONS.TYPE.CREATED, '2024-01-01 08:00:00'); + const iouCreateAction = makeIOUAction('2', '2024-01-01 09:00:00', CONST.IOU.REPORT_ACTION_TYPE.CREATE); + const txnComment = makeAction('3', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 10:00:00'); + const selfDMReport = {chatType: CONST.REPORT.CHAT_TYPE.SELF_DM} as Report; + + const result = getCombinedReportActions([parentCreated, iouCreateAction], 'txnThread1', [txnComment], selfDMReport); + const resultIDs = result.map((a) => a.reportActionID); + expect(resultIDs).not.toContain('2'); + }); + + it('passes report parameter correctly to determine selfDM behavior', () => { + const parentCreated = makeAction('1', CONST.REPORT.ACTIONS.TYPE.CREATED, '2024-01-01 08:00:00'); + const iouTrackAction = makeIOUAction('2', '2024-01-01 09:00:00', CONST.IOU.REPORT_ACTION_TYPE.TRACK); + const txnComment = makeAction('3', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 10:00:00'); + + // Without report (undefined) - TRACK should be filtered + const resultWithoutReport = getCombinedReportActions([parentCreated, iouTrackAction], 'txnThread1', [txnComment], undefined); + expect(resultWithoutReport.map((a) => a.reportActionID)).not.toContain('2'); + + // With selfDM report - TRACK should be kept + const selfDMReport = {chatType: CONST.REPORT.CHAT_TYPE.SELF_DM} as Report; + const resultWithReport = getCombinedReportActions([parentCreated, iouTrackAction], 'txnThread1', [txnComment], selfDMReport); + expect(resultWithReport.map((a) => a.reportActionID)).toContain('2'); + }); + }); }); From be62f95a6453e644267e24ecc4cda68eb0842eae Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Mon, 11 May 2026 15:57:42 +0530 Subject: [PATCH 3/3] Addressing suggestions --- src/libs/OptionsListUtils/index.ts | 3 ++- src/libs/ReportActionsUtils.ts | 8 +----- .../configs/sortedReportActions.ts | 4 ++- .../useLastEditableAction.ts | 2 +- src/pages/inbox/report/ReportActionsView.tsx | 2 +- tests/unit/ReportActionsUtilsTest.ts | 25 ++++++++----------- 6 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 2858017815f1..e3803dc3952d 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -263,7 +263,8 @@ Onyx.connect({ if (transactionThreadReportID) { const transactionThreadReportActionsArray = Object.values(actions[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`] ?? {}); - sortedReportActions = getCombinedReportActions(sortedReportActions, transactionThreadReportID, transactionThreadReportActionsArray, report); + const isSelfDM = report?.chatType === CONST.REPORT.CHAT_TYPE.SELF_DM; + sortedReportActions = getCombinedReportActions(sortedReportActions, transactionThreadReportID, transactionThreadReportActionsArray, isSelfDM); } const firstReportAction = sortedReportActions.at(0); diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 3af6473e0c08..a399ab9ec595 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -785,12 +785,7 @@ function getSortedReportActions(reportActions: ReportAction[] | null, shouldSort * Returns a sorted and filtered list of report actions from a report and it's associated child * transaction thread report in order to correctly display reportActions from both reports in the one-transaction report view. */ -function getCombinedReportActions( - reportActions: ReportAction[], - transactionThreadReportID: string | null, - transactionThreadReportActions: ReportAction[], - report: OnyxEntry, -): ReportAction[] { +function getCombinedReportActions(reportActions: ReportAction[], transactionThreadReportID: string | null, transactionThreadReportActions: ReportAction[], isSelfDM = false): ReportAction[] { const isSentMoneyReport = reportActions.some((action) => isSentMoneyReportAction(action)); // We don't want to combine report actions of transaction thread in iou report of send money request because we display the transaction report of send money request as a normal thread @@ -813,7 +808,6 @@ function getCombinedReportActions( filteredParentReportActions = reportActions?.filter((action) => action.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED); } - const isSelfDM = report?.chatType === CONST.REPORT.CHAT_TYPE.SELF_DM; // Filter out request and send money request actions because we don't want to show any preview actions for one transaction reports const filteredReportActions = [...filteredParentReportActions, ...filteredTransactionThreadReportActions].filter((action) => { if (!isMoneyRequestAction(action)) { diff --git a/src/libs/actions/OnyxDerived/configs/sortedReportActions.ts b/src/libs/actions/OnyxDerived/configs/sortedReportActions.ts index b1da171d04ea..e438196d7706 100644 --- a/src/libs/actions/OnyxDerived/configs/sortedReportActions.ts +++ b/src/libs/actions/OnyxDerived/configs/sortedReportActions.ts @@ -1,6 +1,7 @@ import type {OnyxCollection} from 'react-native-onyx'; import {getCombinedReportActions, getOneTransactionThreadReportID, getSortedReportActions, withDEWRoutedActionsArray} from '@libs/ReportActionsUtils'; import createOnyxDerivedValueConfig from '@userActions/OnyxDerived/createOnyxDerivedValueConfig'; +import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Report, ReportAction, ReportActions} from '@src/types/onyx'; import type {SortedReportActionsDerivedValue} from '@src/types/onyx/DerivedValues'; @@ -23,7 +24,8 @@ function computeForReport( if (transactionThreadReportID && allReportActions) { const transactionThreadReportActionsArray = Object.values(allReportActions[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`] ?? {}); - sortedReportActions = getCombinedReportActions(sortedReportActions, transactionThreadReportID, transactionThreadReportActionsArray, report); + const isSelfDM = report?.chatType === CONST.REPORT.CHAT_TYPE.SELF_DM; + sortedReportActions = getCombinedReportActions(sortedReportActions, transactionThreadReportID, transactionThreadReportActionsArray, isSelfDM); } return { diff --git a/src/pages/inbox/report/ReportActionCompose/useLastEditableAction.ts b/src/pages/inbox/report/ReportActionCompose/useLastEditableAction.ts index c0a146904be9..09e125d898b6 100644 --- a/src/pages/inbox/report/ReportActionCompose/useLastEditableAction.ts +++ b/src/pages/inbox/report/ReportActionCompose/useLastEditableAction.ts @@ -33,7 +33,7 @@ function useLastEditableAction(reportID: string): OnyxEntry (reportActionsToDisplay ? getCombinedReportActions(reportActionsToDisplay, transactionThreadReportID ?? null, transactionThreadReportActions ?? [], undefined) : []), + () => (reportActionsToDisplay ? getCombinedReportActions(reportActionsToDisplay, transactionThreadReportID ?? null, transactionThreadReportActions ?? []) : []), [reportActionsToDisplay, transactionThreadReportActions, transactionThreadReportID], ); diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index 379dec82103f..a23f1f4d26d9 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -5132,14 +5132,14 @@ describe('ReportActionsUtils', () => { it('returns original reportActions when transactionThreadReportID is null', () => { const actions = [makeAction('1', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 10:00:00')]; - const result = getCombinedReportActions(actions, null, [], undefined); + const result = getCombinedReportActions(actions, null, []); expect(result).toEqual(actions); }); it('returns original reportActions for sent money reports', () => { const sentMoneyAction = makeIOUAction('1', '2024-01-01 10:00:00', CONST.IOU.REPORT_ACTION_TYPE.PAY, true); const actions = [sentMoneyAction]; - const result = getCombinedReportActions(actions, 'txnThread1', [makeAction('2', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 11:00:00')], undefined); + const result = getCombinedReportActions(actions, 'txnThread1', [makeAction('2', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 11:00:00')]); expect(result).toEqual(actions); }); @@ -5149,7 +5149,7 @@ describe('ReportActionsUtils', () => { const txnComment = makeAction('3', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 09:00:00'); const txnCreated = makeAction('4', CONST.REPORT.ACTIONS.TYPE.CREATED, '2024-01-01 09:30:00'); - const result = getCombinedReportActions([parentCreated, parentComment], 'txnThread1', [txnCreated, txnComment], undefined); + const result = getCombinedReportActions([parentCreated, parentComment], 'txnThread1', [txnCreated, txnComment]); // parentCreated should be kept since it's older; txnCreated should be filtered out // Result should be sorted descending by created, with CREATED last @@ -5163,7 +5163,7 @@ describe('ReportActionsUtils', () => { const parentCreated = makeAction('1', CONST.REPORT.ACTIONS.TYPE.CREATED, '2024-01-01 10:00:00'); const txnCreated = makeAction('2', CONST.REPORT.ACTIONS.TYPE.CREATED, '2024-01-01 08:00:00'); - const result = getCombinedReportActions([parentCreated], 'txnThread1', [txnCreated], undefined); + const result = getCombinedReportActions([parentCreated], 'txnThread1', [txnCreated]); const actionNames = result.map((a) => a.actionName); // Only one CREATED should be present expect(actionNames.filter((name) => name === CONST.REPORT.ACTIONS.TYPE.CREATED).length).toBe(1); @@ -5174,7 +5174,7 @@ describe('ReportActionsUtils', () => { const iouCreateAction = makeIOUAction('2', '2024-01-01 09:00:00', CONST.IOU.REPORT_ACTION_TYPE.CREATE); const txnComment = makeAction('3', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 10:00:00'); - const result = getCombinedReportActions([parentCreated, iouCreateAction], 'txnThread1', [txnComment], undefined); + const result = getCombinedReportActions([parentCreated, iouCreateAction], 'txnThread1', [txnComment]); const resultIDs = result.map((a) => a.reportActionID); expect(resultIDs).not.toContain('2'); }); @@ -5184,7 +5184,7 @@ describe('ReportActionsUtils', () => { const iouTrackAction = makeIOUAction('2', '2024-01-01 09:00:00', CONST.IOU.REPORT_ACTION_TYPE.TRACK); const txnComment = makeAction('3', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 10:00:00'); - const result = getCombinedReportActions([parentCreated, iouTrackAction], 'txnThread1', [txnComment], undefined); + const result = getCombinedReportActions([parentCreated, iouTrackAction], 'txnThread1', [txnComment]); const resultIDs = result.map((a) => a.reportActionID); expect(resultIDs).not.toContain('2'); }); @@ -5193,9 +5193,8 @@ describe('ReportActionsUtils', () => { const parentCreated = makeAction('1', CONST.REPORT.ACTIONS.TYPE.CREATED, '2024-01-01 08:00:00'); const iouTrackAction = makeIOUAction('2', '2024-01-01 09:00:00', CONST.IOU.REPORT_ACTION_TYPE.TRACK); const txnComment = makeAction('3', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 10:00:00'); - const selfDMReport = {chatType: CONST.REPORT.CHAT_TYPE.SELF_DM} as Report; - const result = getCombinedReportActions([parentCreated, iouTrackAction], 'txnThread1', [txnComment], selfDMReport); + const result = getCombinedReportActions([parentCreated, iouTrackAction], 'txnThread1', [txnComment], true); const resultIDs = result.map((a) => a.reportActionID); expect(resultIDs).toContain('2'); }); @@ -5204,9 +5203,8 @@ describe('ReportActionsUtils', () => { const parentCreated = makeAction('1', CONST.REPORT.ACTIONS.TYPE.CREATED, '2024-01-01 08:00:00'); const iouCreateAction = makeIOUAction('2', '2024-01-01 09:00:00', CONST.IOU.REPORT_ACTION_TYPE.CREATE); const txnComment = makeAction('3', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 10:00:00'); - const selfDMReport = {chatType: CONST.REPORT.CHAT_TYPE.SELF_DM} as Report; - const result = getCombinedReportActions([parentCreated, iouCreateAction], 'txnThread1', [txnComment], selfDMReport); + const result = getCombinedReportActions([parentCreated, iouCreateAction], 'txnThread1', [txnComment], true); const resultIDs = result.map((a) => a.reportActionID); expect(resultIDs).not.toContain('2'); }); @@ -5216,13 +5214,12 @@ describe('ReportActionsUtils', () => { const iouTrackAction = makeIOUAction('2', '2024-01-01 09:00:00', CONST.IOU.REPORT_ACTION_TYPE.TRACK); const txnComment = makeAction('3', CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, '2024-01-01 10:00:00'); - // Without report (undefined) - TRACK should be filtered - const resultWithoutReport = getCombinedReportActions([parentCreated, iouTrackAction], 'txnThread1', [txnComment], undefined); + // Without report - TRACK should be filtered + const resultWithoutReport = getCombinedReportActions([parentCreated, iouTrackAction], 'txnThread1', [txnComment], false); expect(resultWithoutReport.map((a) => a.reportActionID)).not.toContain('2'); // With selfDM report - TRACK should be kept - const selfDMReport = {chatType: CONST.REPORT.CHAT_TYPE.SELF_DM} as Report; - const resultWithReport = getCombinedReportActions([parentCreated, iouTrackAction], 'txnThread1', [txnComment], selfDMReport); + const resultWithReport = getCombinedReportActions([parentCreated, iouTrackAction], 'txnThread1', [txnComment], true); expect(resultWithReport.map((a) => a.reportActionID)).toContain('2'); }); });