Skip to content

Commit

Permalink
Merge pull request Expensify#31172 from DylanDylann/fix/30378
Browse files Browse the repository at this point in the history
  • Loading branch information
cead22 authored Nov 16, 2023
2 parents 06ddd6e + 1b7fc3a commit 235ede8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,10 @@ function buildOnyxDataForMoneyRequest(
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`,
value: {pendingAction: null},
value: {
pendingAction: null,
pendingFields: null,
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down Expand Up @@ -301,6 +304,7 @@ function buildOnyxDataForMoneyRequest(
hasOutstandingIOU: chatReport.hasOutstandingIOU,
iouReportID: chatReport.iouReportID,
lastReadTime: chatReport.lastReadTime,
pendingFields: null,
...(isNewChatReport
? {
errorFields: {
Expand All @@ -316,6 +320,7 @@ function buildOnyxDataForMoneyRequest(
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`,
value: {
pendingFields: null,
errorFields: {
createChat: ErrorUtils.getMicroSecondOnyxError('report.genericCreateReportFailureMessage'),
},
Expand All @@ -328,6 +333,8 @@ function buildOnyxDataForMoneyRequest(
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`,
value: {
errors: ErrorUtils.getMicroSecondOnyxError('iou.error.genericCreateFailureMessage'),
pendingAction: null,
pendingFields: null,
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function addStop(transactionID: string) {
function saveWaypoint(transactionID: string, index: string, waypoint: RecentWaypoint | null, isEditingWaypoint = false) {
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {
pendingFields: {
comment: isEditingWaypoint ? CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE : CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
waypoints: isEditingWaypoint ? CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE : CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
},
comment: {
waypoints: {
Expand Down
2 changes: 1 addition & 1 deletion src/types/onyx/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type Transaction = {
routes?: Routes;
transactionID: string;
tag: string;
pendingFields?: Partial<{[K in keyof Transaction]: ValueOf<typeof CONST.RED_BRICK_ROAD_PENDING_ACTION>}>;
pendingFields?: Partial<{[K in keyof Transaction | keyof Comment]: ValueOf<typeof CONST.RED_BRICK_ROAD_PENDING_ACTION>}>;

/** Card Transactions */

Expand Down
2 changes: 1 addition & 1 deletion tests/actions/IOUTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ describe('actions/IOU', () => {
waitForCollectionCallback: true,
callback: (transaction) => {
Onyx.disconnect(connectionID);
expect(transaction.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD);
expect(transaction.pendingAction).toBeFalsy();
expect(transaction.errors).toBeTruthy();
expect(_.values(transaction.errors)[0]).toBe('iou.error.genericCreateFailureMessage');
resolve();
Expand Down

0 comments on commit 235ede8

Please sign in to comment.