From e6d4e45c8215d909c278e24f23746d24531e76c3 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 25 Jun 2024 11:10:48 +0800 Subject: [PATCH 1/4] only clear the transaction if it's failed to create --- src/components/ReportActionItem/MoneyRequestView.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 5db3f92d5493..a0d73a1b2844 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -404,7 +404,10 @@ function MoneyRequestView({ if (!transaction?.transactionID) { return; } - if (Object.values(transaction?.errors ?? {})?.find((error) => ErrorUtils.isReceiptError(error))) { + if ( + transaction.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && + Object.values(transaction?.errors ?? {})?.find((error) => ErrorUtils.isReceiptError(error)) + ) { deleteTransaction(parentReport, parentReportAction); } Transaction.clearError(transaction.transactionID); From 345bb749f9ec80fd2de6bc7b2c874cd6f695d611 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 25 Jun 2024 11:40:25 +0800 Subject: [PATCH 2/4] dont clear pending action when fails --- src/libs/actions/IOU.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index bc4569bf4603..364fb19d3b35 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -798,7 +798,6 @@ function buildOnyxDataForMoneyRequest( // Disabling this line since transaction.filename can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing errors: getReceiptError(transaction.receipt, transaction.filename || transaction.receipt?.filename, isScanRequest, errorKey), - pendingAction: null, pendingFields: clearedPendingFields, }, }, @@ -1524,7 +1523,6 @@ function buildOnyxDataForTrackExpense( // Disabling this line since transaction.filename can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing errors: getReceiptError(transaction.receipt, transaction.filename || transaction.receipt?.filename, isScanRequest), - pendingAction: null, pendingFields: clearedPendingFields, }, }, @@ -5567,6 +5565,7 @@ function deleteMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repor API.write(WRITE_COMMANDS.DELETE_MONEY_REQUEST, parameters, {optimisticData, successData, failureData}); CachedPDFPaths.clearByKey(transactionID); + console.log('delete transaction thread?', {isSingleTransactionView, shouldDeleteIOUReport, shouldDeleteTransactionThread, iouReport}) // STEP 7: Navigate the user depending on which page they are on and which resources were deleted if (iouReport && isSingleTransactionView && shouldDeleteTransactionThread && !shouldDeleteIOUReport) { // Pop the deleted report screen before navigating. This prevents navigating to the Concierge chat due to the missing report. From 513763ef90def3b8bc2b3ed6daae15fb3721a964 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 25 Jun 2024 11:43:43 +0800 Subject: [PATCH 3/4] remove log --- src/libs/actions/IOU.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 364fb19d3b35..fd95947c5153 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -5565,7 +5565,6 @@ function deleteMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repor API.write(WRITE_COMMANDS.DELETE_MONEY_REQUEST, parameters, {optimisticData, successData, failureData}); CachedPDFPaths.clearByKey(transactionID); - console.log('delete transaction thread?', {isSingleTransactionView, shouldDeleteIOUReport, shouldDeleteTransactionThread, iouReport}) // STEP 7: Navigate the user depending on which page they are on and which resources were deleted if (iouReport && isSingleTransactionView && shouldDeleteTransactionThread && !shouldDeleteIOUReport) { // Pop the deleted report screen before navigating. This prevents navigating to the Concierge chat due to the missing report. From 3c6bd131de88fac5429bfd837a894ea21fe47a78 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 25 Jun 2024 13:04:32 +0800 Subject: [PATCH 4/4] fox test --- tests/actions/IOUTest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index fbd31012b023..d407c1aab2d2 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -774,7 +774,7 @@ describe('actions/IOU', () => { waitForCollectionCallback: false, callback: (transaction) => { Onyx.disconnect(connectionID); - expect(transaction?.pendingAction).toBeFalsy(); + expect(transaction?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD); expect(transaction?.errors).toBeTruthy(); expect(Object.values(transaction?.errors ?? {})[0]).toEqual(Localize.translateLocal('iou.error.genericCreateFailureMessage')); resolve();