diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 0f996fbe8c029..fb4c56a05a72f 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -11188,6 +11188,18 @@ function updateLastLocationPermissionPrompt() { Onyx.set(ONYXKEYS.NVP_LAST_LOCATION_PERMISSION_PROMPT, new Date().toISOString()); } +function setMultipleMoneyRequestParticipantsFromReport(transactionIDs: string[], reportValue: OnyxEntry) { + const participants = getMoneyRequestParticipantsFromReport(reportValue); + const updatedTransactions: Record<`${typeof ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${string}`, NullishDeep> = {}; + transactionIDs.forEach((transactionID) => { + updatedTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`] = { + participants, + participantsAutoAssigned: true, + }; + }); + return Onyx.mergeCollection(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, updatedTransactions); +} + /** Instead of merging the duplicates, it updates the transaction we want to keep and puts the others on hold without deleting them */ function resolveDuplicates(params: MergeDuplicatesParams) { if (!params.transactionID) { @@ -11892,6 +11904,7 @@ export { setMoneyRequestParticipantsFromReport, getMoneyRequestParticipantsFromReport, setMoneyRequestPendingFields, + setMultipleMoneyRequestParticipantsFromReport, setMoneyRequestReceipt, setMoneyRequestTag, setMoneyRequestTaxAmount, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 0a1e1fc46fddc..28addfa2ca32c 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -61,6 +61,7 @@ import { setMoneyRequestParticipants, setMoneyRequestParticipantsFromReport, setMoneyRequestReceipt, + setMultipleMoneyRequestParticipantsFromReport, startSplitBill, trackExpense, updateLastLocationPermissionPrompt, @@ -497,9 +498,8 @@ function IOURequestStepScan({ createTransaction(files, participant); return; } - - const setParticipantsPromises = files.map((receiptFile) => setMoneyRequestParticipantsFromReport(receiptFile.transactionID, report)); - Promise.all(setParticipantsPromises).then(() => navigateToConfirmationPage()); + const transactionIDs = files.map((receiptFile) => receiptFile.transactionID); + setMultipleMoneyRequestParticipantsFromReport(transactionIDs, report).then(() => navigateToConfirmationPage()); return; }