Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify failure data for request/send money and make it more consistent with SplitBill #18328

Merged
merged 6 commits into from
May 9, 2023
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: 9 additions & 0 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ function requestMoney(report, amount, currency, recipientEmail, participant, com
errorFields: null,
},
};
chatReportFailureData.value.pendingFields = {createChat: null};
delete chatReportFailureData.value.hasOutstandingIOU;
chatReportFailureData.value.errorFields = {
createChat: {
[DateUtils.getMicroseconds()]: Localize.translateLocal('report.genericCreateReportFailureMessage'),
Expand All @@ -198,6 +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};

// 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 = [
Expand Down Expand Up @@ -927,6 +933,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 = [
Expand Down
2 changes: 0 additions & 2 deletions tests/actions/IOUTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
});
Expand Down