Skip to content

Commit

Permalink
Merge pull request #44364 from bernhardoj/fix/44246-existing-transact…
Browse files Browse the repository at this point in the history
…ion-is-removed

[CP Staging] Fix existing expense is removed when dismissing receipt error
  • Loading branch information
cristipaval authored Jun 25, 2024
2 parents fd4987f + 3c6bd13 commit e2040ff
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
Expand Down Expand Up @@ -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,
},
},
Expand Down
2 changes: 1 addition & 1 deletion tests/actions/IOUTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e2040ff

Please sign in to comment.