Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In here we should update pendingFields.waypoints like we did when changing waypoint in EditRequestPage

const pendingFields = _.mapObject(transactionChanges, () => CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE);

I log pendingFields here anh Let's see this video

Screen-Recording-2023-11-10-at-14.57.38.mp4

},
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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the pending action changed to false instead of add?

@DylanDylann DylanDylann Nov 15, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ArekChr In this UT case, there are some errors while creating transaction. We removed pendingAction in FailureData in the logic so we also need to update UTs here

expect(transaction.errors).toBeTruthy();
expect(_.values(transaction.errors)[0]).toBe('iou.error.genericCreateFailureMessage');
resolve();
Expand Down