Skip to content

Commit

Permalink
Always update successData
Browse files Browse the repository at this point in the history
  • Loading branch information
cristipaval committed Jul 10, 2023
1 parent 201f426 commit c379a5c
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ function buildOnyxDataForMoneyRequest(
reportPreviewAction,
isNewChatReport,
isNewIOUReport,
isNewReportPreviewAction,
) {
const optimisticData = [
{
Expand Down Expand Up @@ -187,13 +186,9 @@ function buildOnyxDataForMoneyRequest(
},
}
: {}),
...(isNewReportPreviewAction
? {
[reportPreviewAction.reportActionID]: {
pendingAction: null,
},
}
: {}),
[reportPreviewAction.reportActionID]: {
pendingAction: null,
},
},
},
{
Expand Down Expand Up @@ -385,15 +380,13 @@ function requestMoney(report, amount, currency, payeeEmail, payeeAccountID, part
},
};

let isNewReportPreviewAction = false;
let reportPreviewAction = isNewIOUReport ? null : ReportActionsUtils.getReportPreviewAction(chatReport.reportID, iouReport.reportID);
if (reportPreviewAction) {
reportPreviewAction.created = DateUtils.getDBTime();
const message = ReportUtils.getReportPreviewMessage(iouReport, reportPreviewAction);
reportPreviewAction.message[0].html = message;
reportPreviewAction.message[0].text = message;
} else {
isNewReportPreviewAction = true;
reportPreviewAction = ReportUtils.buildOptimisticReportPreview(chatReport, iouReport);
}

Expand All @@ -409,7 +402,6 @@ function requestMoney(report, amount, currency, payeeEmail, payeeAccountID, part
reportPreviewAction,
isNewChatReport,
isNewIOUReport,
isNewReportPreviewAction,
);

// STEP 6: Make the request
Expand Down Expand Up @@ -652,15 +644,13 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco
},
};

let isNewOneOnOneReportPreviewAction = false;
let oneOnOneReportPreviewAction = ReportActionsUtils.getReportPreviewAction(oneOnOneChatReport.reportID, oneOnOneIOUReport.reportID);
if (oneOnOneReportPreviewAction) {
oneOnOneReportPreviewAction.created = DateUtils.getDBTime();
const message = ReportUtils.getReportPreviewMessage(oneOnOneIOUReport, oneOnOneReportPreviewAction);
oneOnOneReportPreviewAction.message[0].html = message;
oneOnOneReportPreviewAction.message[0].text = message;
} else {
isNewOneOnOneReportPreviewAction = true;
oneOnOneReportPreviewAction = ReportUtils.buildOptimisticReportPreview(oneOnOneChatReport, oneOnOneIOUReport);
}

Expand All @@ -676,7 +666,6 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco
oneOnOneReportPreviewAction,
isNewOneOnOneChatReport,
isNewOneOnOneIOUReport,
isNewOneOnOneReportPreviewAction,
);

const splitData = {
Expand Down

0 comments on commit c379a5c

Please sign in to comment.