Skip to content

Commit

Permalink
Merge pull request #13502 from Expensify/youssef_createdReportAction_…
Browse files Browse the repository at this point in the history
…ious

Add createdReportActionID to sendMoney and requestMoney
  • Loading branch information
mountiny authored Jan 16, 2023
2 parents 8662d3d + a30cd3c commit 2552208
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ function requestMoney(report, amount, currency, recipientEmail, participant, com
},
];

let optimisticCreatedAction;

// Now, let's add the data we need just when we are creating a new chat report
if (isNewChat) {
const optimisticCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(recipientEmail);
optimisticCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(recipientEmail);

// Change the method to set for new reports because it doesn't exist yet, is faster,
// and we need the data to be available when we navigate to the chat page
Expand Down Expand Up @@ -218,6 +220,7 @@ function requestMoney(report, amount, currency, recipientEmail, participant, com
chatReportID: chatReport.reportID,
transactionID: optimisticReportAction.originalMessage.IOUTransactionID,
reportActionID: optimisticReportAction.reportActionID,
createdReportActionID: isNewChat ? optimisticCreatedAction[0].reportActionID : 0,
clientID: optimisticReportAction.sequenceNumber,
}, {optimisticData, successData, failureData});
Navigation.navigate(ROUTES.getReportRoute(chatReport.reportID));
Expand Down Expand Up @@ -756,9 +759,11 @@ function getSendMoneyParams(report, amount, currency, comment, paymentMethodType
},
];

let optimisticCreatedAction;

// Now, let's add the data we need just when we are creating a new chat report
if (isNewChat) {
const optimisticCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(recipientEmail);
optimisticCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(recipientEmail);

// Change the method to set for new reports because it doesn't exist yet, is faster,
// and we need the data to be available when we navigate to the chat page
Expand All @@ -784,6 +789,7 @@ function getSendMoneyParams(report, amount, currency, comment, paymentMethodType
transactionID: optimisticIOUReportAction.originalMessage.IOUTransactionID,
clientID: optimisticIOUReportAction.sequenceNumber,
newIOUReportDetails,
createdReportActionID: isNewChat ? optimisticCreatedAction[0].reportActionID : 0,
},
optimisticData,
successData,
Expand Down

0 comments on commit 2552208

Please sign in to comment.