Skip to content

Commit b1637c2

Browse files
authored
Merge pull request Expensify#67339 from ZhenjaHorbach/splits-use-reportID-from-transaction
Split expense - Not here page opens when try to split expense
2 parents 344a393 + 5cb201c commit b1637c2

4 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/components/MoneyReportHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ function MoneyReportHeader({
844844
}
845845

846846
const currentTransaction = transactions.at(0);
847-
initSplitExpense(currentTransaction, moneyRequestReport?.reportID ?? String(CONST.DEFAULT_NUMBER_ID));
847+
initSplitExpense(currentTransaction);
848848
},
849849
},
850850
[CONST.REPORT.SECONDARY_ACTIONS.CHANGE_WORKSPACE]: {

src/components/MoneyRequestHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ function MoneyRequestHeader({report, parentReportAction, policy, onBackButtonPre
240240
icon: Expensicons.ArrowSplit,
241241
value: CONST.REPORT.SECONDARY_ACTIONS.SPLIT,
242242
onSelected: () => {
243-
initSplitExpense(transaction, reportID ?? String(CONST.DEFAULT_NUMBER_ID));
243+
initSplitExpense(transaction);
244244
},
245245
},
246246
[CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.VIEW_DETAILS]: {

src/libs/actions/IOU.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11670,11 +11670,13 @@ function getSearchOnyxUpdate({
1167011670
/**
1167111671
* Create a draft transaction to set up split expense details for the split expense flow
1167211672
*/
11673-
function initSplitExpense(transaction: OnyxEntry<OnyxTypes.Transaction>, reportID: string, isOpenCreatedSplit?: boolean) {
11673+
function initSplitExpense(transaction: OnyxEntry<OnyxTypes.Transaction>, isOpenCreatedSplit?: boolean) {
1167411674
if (!transaction) {
1167511675
return;
1167611676
}
1167711677

11678+
const reportID = transaction?.reportID ?? String(CONST.DEFAULT_NUMBER_ID);
11679+
1167811680
if (isOpenCreatedSplit) {
1167911681
const originalTransactionID = transaction.comment?.originalTransactionID;
1168011682
const originalTransaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${originalTransactionID}`];

tests/actions/IOUTest.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6132,9 +6132,7 @@ describe('actions/IOU', () => {
61326132
reportID: '456',
61336133
};
61346134

6135-
const reportID = '456';
6136-
6137-
initSplitExpense(transaction, reportID);
6135+
initSplitExpense(transaction);
61386136
await waitForBatchedUpdates();
61396137

61406138
const draftTransaction = await getOnyxValue(`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transaction.transactionID}`);
@@ -6146,7 +6144,7 @@ describe('actions/IOU', () => {
61466144
expect(draftTransaction?.amount).toBe(100);
61476145
expect(draftTransaction?.currency).toBe('USD');
61486146
expect(draftTransaction?.merchant).toBe('Test Merchant');
6149-
expect(draftTransaction?.reportID).toBe(reportID);
6147+
expect(draftTransaction?.reportID).toBe(transaction.reportID);
61506148

61516149
expect(splitExpenses?.[0].amount).toBe(50);
61526150
expect(splitExpenses?.[0].description).toBe('Test comment');
@@ -6160,9 +6158,8 @@ describe('actions/IOU', () => {
61606158
});
61616159
it('should not initialize split expense for null transaction', async () => {
61626160
const transaction: Transaction | undefined = undefined;
6163-
const reportID = '456';
61646161

6165-
initSplitExpense(transaction, reportID);
6162+
initSplitExpense(transaction);
61666163
await waitForBatchedUpdates();
61676164

61686165
expect(transaction).toBeFalsy();

0 commit comments

Comments
 (0)