Skip to content
Merged
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
10 changes: 9 additions & 1 deletion src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11736,7 +11736,7 @@ function mergeDuplicates({transactionThreadReportID: optimisticTransactionThread
value: optimisticTransactionThreadReport,
},
{
onyxMethod: Onyx.METHOD.SET,
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${optimisticTransactionThreadReportID}`,
value: {[optimisticCreatedAction.reportActionID]: optimisticCreatedAction},
},
Expand All @@ -11756,6 +11756,14 @@ function mergeDuplicates({transactionThreadReportID: optimisticTransactionThread
);

if (iouAction?.reportActionID) {
// Context: Right now updates provided in one Onyx.update can reach component in different renders.
// This is because `Onyx.merge` is batched and `Onyx.set` is not, so it may not be necessary after https://github.com/Expensify/App/issues/71207 is resolved.
// Setting up the transactions null values (removing of the transactions) happens faster than setting of optimistic childReportID,
// though both updates come from one optimistic data.
// To escape unexpected effects we setting the childReportID using Onyx.merge, making sure it will be in place when transactions are cleared out.
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${optimisticTransactionThreadReport?.parentReportID}`, {
[iouAction?.reportActionID]: {childReportID: optimisticTransactionThreadReportID, childType: CONST.REPORT.TYPE.CHAT},
});
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${optimisticTransactionThreadReport?.parentReportID}`,
Expand Down