From 63511d661270a2e9d697a434c7c4c9c66b449868 Mon Sep 17 00:00:00 2001 From: daledah Date: Tue, 8 Oct 2024 16:28:27 +0700 Subject: [PATCH] fix: report header has "Hold" action when the expense is already in Hold status --- src/libs/actions/IOU.ts | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index e16ab39daf5c..2660ae9ca8f6 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -8348,9 +8348,30 @@ function resolveDuplicates(params: TransactionMergeParams) { const optimisticHoldActions: OnyxUpdate[] = []; const failureHoldActions: OnyxUpdate[] = []; const reportActionIDList: string[] = []; + const optimisticHoldTransactionActions: OnyxUpdate[] = []; + const failureHoldTransactionActions: OnyxUpdate[] = []; transactionThreadReportIDList.forEach((transactionThreadReportID) => { const createdReportAction = ReportUtils.buildOptimisticHoldReportAction(); reportActionIDList.push(createdReportAction.reportActionID); + const transactionID = TransactionUtils.getTransactionID(transactionThreadReportID ?? '-1'); + optimisticHoldTransactionActions.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, + value: { + comment: { + hold: createdReportAction.reportActionID, + }, + }, + }); + failureHoldTransactionActions.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, + value: { + comment: { + hold: null, + }, + }, + }); optimisticHoldActions.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`, @@ -8394,8 +8415,8 @@ function resolveDuplicates(params: TransactionMergeParams) { const optimisticData: OnyxUpdate[] = []; const failureData: OnyxUpdate[] = []; - optimisticData.push(optimisticTransactionData, ...optimisticTransactionViolations, ...optimisticHoldActions, optimisticReportActionData); - failureData.push(failureTransactionData, ...failureTransactionViolations, ...failureHoldActions, failureReportActionData); + optimisticData.push(optimisticTransactionData, ...optimisticTransactionViolations, ...optimisticHoldActions, ...optimisticHoldTransactionActions, optimisticReportActionData); + failureData.push(failureTransactionData, ...failureTransactionViolations, ...failureHoldActions, ...failureHoldTransactionActions, failureReportActionData); const {reportID, transactionIDList, receiptID, ...otherParams} = params; const parameters: ResolveDuplicatesParams = {