Skip to content

Commit

Permalink
Merge pull request #12192 from Expensify/cmartins-fixTempReportPage
Browse files Browse the repository at this point in the history
Use Onyx set if creating new report

(cherry picked from commit 2e3aafe)
  • Loading branch information
chiragsalian authored and OSBotify committed Oct 27, 2022
1 parent 78d7dae commit cd7df2d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,18 +235,20 @@ function requestMoney(report, amount, currency, recipientEmail, debtorEmail, com
// Now, let's add the data we need just when we are creating a new chat report
if (isNewChat) {
const optimisticCreateAction = 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
optimisticData[0].onyxMethod = CONST.ONYX.METHOD.SET;
optimisticData[0].value = {
...optimisticData[0].value,
pendingFields: {createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD},
};
optimisticData.push(
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport.reportID}`,
value: optimisticCreateAction,
},
);

optimisticData[1].onyxMethod = CONST.ONYX.METHOD.SET;
optimisticData[1].value = {
...optimisticCreateAction,
...optimisticData[1].value,
};
optimisticData[2].onyxMethod = CONST.ONYX.METHOD.SET;
successData.push(
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
Expand Down

0 comments on commit cd7df2d

Please sign in to comment.