From b74a6b1055c45162fb68830c89491945840cc670 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 17 Jul 2024 18:09:56 +0800 Subject: [PATCH] optimistically remove the hold violation --- src/libs/actions/IOU.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index d710c06c0d0d..40403eded27f 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -7060,6 +7060,7 @@ function putOnHold(transactionID: string, comment: string, reportID: string) { */ function unholdRequest(transactionID: string, reportID: string) { const createdReportAction = ReportUtils.buildOptimisticUnHoldReportAction(); + const transactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`]; const optimisticData: OnyxUpdate[] = [ { @@ -7079,6 +7080,11 @@ function unholdRequest(transactionID: string, reportID: string) { }, }, }, + { + onyxMethod: Onyx.METHOD.SET, + key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, + value: transactionViolations?.filter((violation) => violation.name !== CONST.VIOLATIONS.HOLD) ?? [], + }, ]; const successData: OnyxUpdate[] = [ @@ -7103,6 +7109,11 @@ function unholdRequest(transactionID: string, reportID: string) { errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('iou.error.genericUnholdExpenseFailureMessage'), }, }, + { + onyxMethod: Onyx.METHOD.SET, + key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, + value: transactionViolations ?? null, + }, ]; API.write(