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); diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index bc4569bf4603..fd95947c5153 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, }, }, 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();