From 784751bc2d26d3d91abfc548610f93a7988daa2a Mon Sep 17 00:00:00 2001 From: war-in Date: Thu, 25 Jul 2024 13:36:19 +0200 Subject: [PATCH 1/3] update total of the old report --- src/libs/actions/IOU.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 4690e2ca284d..6002ab1101a1 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -6314,6 +6314,14 @@ function getReportFromHoldRequestsOnyxData( [optimisticExpenseReportPreview.reportActionID]: optimisticExpenseReportPreview, }, }, + // update total of the old iou report + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`, + value: { + total: !!iouReport?.total ? iouReport.total - (firstHoldTransaction?.amount ?? 0) : 0, + }, + }, // remove hold report actions from old iou report { onyxMethod: Onyx.METHOD.MERGE, From f41326c5635526e7506d512436e4f76b001181b0 Mon Sep 17 00:00:00 2001 From: war-in Date: Thu, 25 Jul 2024 13:37:24 +0200 Subject: [PATCH 2/3] reset total on failure --- src/libs/actions/IOU.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 6002ab1101a1..6b700ab20821 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -6373,6 +6373,14 @@ function getReportFromHoldRequestsOnyxData( [optimisticExpenseReportPreview.reportActionID]: null, }, }, + // reset total of the old iou report + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`, + value: { + total: iouReport?.total, + }, + }, // add hold report actions back to old iou report { onyxMethod: Onyx.METHOD.MERGE, From 3ee83fa641bf0e0345e07fd8b4265aea9451fa82 Mon Sep 17 00:00:00 2001 From: war-in Date: Thu, 25 Jul 2024 13:44:26 +0200 Subject: [PATCH 3/3] fix lint --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 6b700ab20821..3891d03d6419 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -6319,7 +6319,7 @@ function getReportFromHoldRequestsOnyxData( onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`, value: { - total: !!iouReport?.total ? iouReport.total - (firstHoldTransaction?.amount ?? 0) : 0, + total: iouReport?.total !== undefined ? iouReport.total - (firstHoldTransaction?.amount ?? 0) : 0, }, }, // remove hold report actions from old iou report