From 8cf3c29475b448f1f08287b75ae28abd62277882 Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Tue, 2 May 2023 22:16:10 -0700 Subject: [PATCH 1/4] Fix Request Money flow to be consistent with split bill when creating a new report for failure data --- src/libs/actions/IOU.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 050c1b0e7f6b..b6f625dd2b34 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -167,12 +167,16 @@ function requestMoney(report, amount, currency, recipientEmail, participant, com errorFields: null, }, }; - chatReportFailureData.value.pendingFields = null; + chatReportFailureData.value.pendingFields = {createChat: null}; + delete chatReportFailureData.value.hasOutstandingIOU; // Then add an optimistic created action optimisticReportActionsData.value[optimisticCreatedAction.reportActionID] = optimisticCreatedAction; reportActionsSuccessData.value[optimisticCreatedAction.reportActionID] = {pendingAction: null}; reportActionsFailureData.value[optimisticCreatedAction.reportActionID] = {pendingAction: null}; + + // If we're going to fail to create the report itself, let's not have redundant error messages for the IOU + reportActionsFailureData.value[optimisticReportAction.reportActionID] = {pendingAction: null}; } const optimisticData = [ From 07411dced2730baffd27575db16e37663eb5b394 Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Tue, 2 May 2023 22:31:42 -0700 Subject: [PATCH 2/4] Make send money flow consistent with split bill --- src/libs/actions/IOU.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index b6f625dd2b34..128adb24e0fb 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -776,6 +776,9 @@ function getSendMoneyParams(report, amount, currency, comment, paymentMethodType // Add an optimistic created action to the optimistic reportActions data optimisticReportActionsData.value[optimisticCreatedAction.reportActionID] = optimisticCreatedAction; + + // If we're going to fail to create the report itself, let's not have redundant error messages for the IOU + failureData[0].value[optimisticIOUReportAction.reportActionID] = {pendingAction: null}; } const optimisticData = [ From 866c94f3c47c93c4988c3cbe2b49b4d78fa8fb95 Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Mon, 8 May 2023 14:22:05 -0700 Subject: [PATCH 3/4] Fix conflicts just a tad better: --- src/libs/actions/IOU.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index d4d768e90520..e1244b6e1426 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -200,10 +200,10 @@ function requestMoney(report, amount, currency, recipientEmail, participant, com // Then add an optimistic created action optimisticReportActionsData.value[optimisticCreatedAction.reportActionID] = optimisticCreatedAction; reportActionsSuccessData.value[optimisticCreatedAction.reportActionID] = {pendingAction: null}; - reportActionsFailureData.value[optimisticCreatedAction.reportActionID] = {pendingAction: null}; - // If we're going to fail to create the report itself, let's not have redundant error messages for the IOU - reportActionsFailureData.value[optimisticReportAction.reportActionID] = {pendingAction: null}; + // Failure data should feature red brick road + reportActionsFailureData.value[optimisticCreatedAction.reportActionID] = {pendingAction: null}; + reportActionsFailureData.value[optimisticReportAction.reportActionID] = {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}; } const optimisticData = [ From 1a7f2e33de09fb3732165121fb6c0c0079dd0d23 Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Mon, 8 May 2023 14:38:08 -0700 Subject: [PATCH 4/4] Get rid of check for redundant error on iou chat --- tests/actions/IOUTest.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/actions/IOUTest.js b/tests/actions/IOUTest.js index 49c59e418239..97f2849f96e0 100644 --- a/tests/actions/IOUTest.js +++ b/tests/actions/IOUTest.js @@ -583,8 +583,6 @@ describe('actions/IOU', () => { expect(_.size(reportActionsForChatReport)).toBe(2); iouAction = _.find(reportActionsForChatReport, reportAction => reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU); expect(iouAction.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD); - const errorMessage = _.values(iouAction.errors)[0]; - expect(errorMessage).toBe(Localize.translateLocal('iou.error.genericCreateFailureMessage')); resolve(); }, });