From 45c69729b8581cf218052669faaf86381b1eef3c Mon Sep 17 00:00:00 2001 From: Yauheni Horbach Date: Tue, 29 Jul 2025 17:53:48 +0200 Subject: [PATCH 1/2] Fix issue --- src/components/MoneyReportHeader.tsx | 2 +- src/components/MoneyRequestHeader.tsx | 2 +- src/libs/actions/IOU.ts | 4 +++- tests/actions/IOUTest.ts | 5 ++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 95e18a22c32..f74a26af9cc 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -844,7 +844,7 @@ function MoneyReportHeader({ } const currentTransaction = transactions.at(0); - initSplitExpense(currentTransaction, moneyRequestReport?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)); + initSplitExpense(currentTransaction); }, }, [CONST.REPORT.SECONDARY_ACTIONS.CHANGE_WORKSPACE]: { diff --git a/src/components/MoneyRequestHeader.tsx b/src/components/MoneyRequestHeader.tsx index 5943018af1e..0d1aa00f62c 100644 --- a/src/components/MoneyRequestHeader.tsx +++ b/src/components/MoneyRequestHeader.tsx @@ -240,7 +240,7 @@ function MoneyRequestHeader({report, parentReportAction, policy, onBackButtonPre icon: Expensicons.ArrowSplit, value: CONST.REPORT.SECONDARY_ACTIONS.SPLIT, onSelected: () => { - initSplitExpense(transaction, reportID ?? String(CONST.DEFAULT_NUMBER_ID)); + initSplitExpense(transaction); }, }, [CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.VIEW_DETAILS]: { diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 2cf7c3150e7..95ee380775a 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -11661,11 +11661,13 @@ function getSearchOnyxUpdate({ /** * Create a draft transaction to set up split expense details for the split expense flow */ -function initSplitExpense(transaction: OnyxEntry, reportID: string, isOpenCreatedSplit?: boolean) { +function initSplitExpense(transaction: OnyxEntry, isOpenCreatedSplit?: boolean) { if (!transaction) { return; } + const reportID = transaction?.reportID ?? String(CONST.DEFAULT_NUMBER_ID); + if (isOpenCreatedSplit) { const originalTransactionID = transaction.comment?.originalTransactionID; const originalTransaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${originalTransactionID}`]; diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index 8cf87fd8468..86c0a1694f1 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -6074,7 +6074,7 @@ describe('actions/IOU', () => { const reportID = '456'; - initSplitExpense(transaction, reportID); + initSplitExpense(transaction); await waitForBatchedUpdates(); const draftTransaction = await getOnyxValue(`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transaction.transactionID}`); @@ -6100,9 +6100,8 @@ describe('actions/IOU', () => { }); it('should not initialize split expense for null transaction', async () => { const transaction: Transaction | undefined = undefined; - const reportID = '456'; - initSplitExpense(transaction, reportID); + initSplitExpense(transaction); await waitForBatchedUpdates(); expect(transaction).toBeFalsy(); From 5cb201cc53460e0f909922da0973f3520b2ec7bb Mon Sep 17 00:00:00 2001 From: Yauheni Horbach Date: Tue, 29 Jul 2025 18:08:37 +0200 Subject: [PATCH 2/2] Update tests --- tests/actions/IOUTest.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index 86c0a1694f1..e82dcc98c8a 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -6072,8 +6072,6 @@ describe('actions/IOU', () => { reportID: '456', }; - const reportID = '456'; - initSplitExpense(transaction); await waitForBatchedUpdates(); @@ -6086,7 +6084,7 @@ describe('actions/IOU', () => { expect(draftTransaction?.amount).toBe(100); expect(draftTransaction?.currency).toBe('USD'); expect(draftTransaction?.merchant).toBe('Test Merchant'); - expect(draftTransaction?.reportID).toBe(reportID); + expect(draftTransaction?.reportID).toBe(transaction.reportID); expect(splitExpenses?.[0].amount).toBe(50); expect(splitExpenses?.[0].description).toBe('Test comment');