Skip to content

Commit bcb8641

Browse files
authored
Merge pull request #51940 from truph01/fix/50022
2 parents e8212bd + f104ffd commit bcb8641

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

src/components/ReportActionItem/MoneyRequestView.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,7 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals
468468
return;
469469
}
470470
if (parentReportAction) {
471-
const urlToNavigateBack = IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true);
472-
Navigation.goBack(urlToNavigateBack);
471+
IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true);
473472
return;
474473
}
475474
}

src/libs/actions/IOU.ts

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5737,27 +5737,28 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo
57375737
// build Onyx data
57385738

57395739
// Onyx operations to delete the transaction, update the IOU report action and chat report action
5740+
const reportActionsOnyxUpdates: OnyxUpdate[] = [];
57405741
const onyxUpdates: OnyxUpdate[] = [
57415742
{
57425743
onyxMethod: Onyx.METHOD.SET,
57435744
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
57445745
value: null,
57455746
},
5746-
{
5747-
onyxMethod: Onyx.METHOD.MERGE,
5748-
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`,
5749-
value: {
5750-
[reportAction.reportActionID]: shouldDeleteIOUReport
5751-
? null
5752-
: {
5753-
pendingAction: null,
5754-
},
5755-
},
5756-
},
57575747
];
5748+
reportActionsOnyxUpdates.push({
5749+
onyxMethod: Onyx.METHOD.MERGE,
5750+
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`,
5751+
value: {
5752+
[reportAction.reportActionID]: shouldDeleteIOUReport
5753+
? null
5754+
: {
5755+
pendingAction: null,
5756+
},
5757+
},
5758+
});
57585759

57595760
if (reportPreviewAction?.reportActionID) {
5760-
onyxUpdates.push({
5761+
reportActionsOnyxUpdates.push({
57615762
onyxMethod: Onyx.METHOD.MERGE,
57625763
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
57635764
value: {
@@ -5794,12 +5795,12 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo
57945795
}
57955796

57965797
// added operations to update IOU report and chat report
5798+
reportActionsOnyxUpdates.push({
5799+
onyxMethod: Onyx.METHOD.MERGE,
5800+
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`,
5801+
value: updatedReportAction,
5802+
});
57975803
onyxUpdates.push(
5798-
{
5799-
onyxMethod: Onyx.METHOD.MERGE,
5800-
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`,
5801-
value: updatedReportAction,
5802-
},
58035804
{
58045805
onyxMethod: Onyx.METHOD.MERGE,
58055806
key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`,
@@ -5850,9 +5851,14 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo
58505851
);
58515852
}
58525853

5853-
Onyx.update(onyxUpdates);
5854-
5855-
return urlToNavigateBack;
5854+
// First, update the reportActions to ensure related actions are not displayed.
5855+
Onyx.update(reportActionsOnyxUpdates).then(() => {
5856+
Navigation.goBack(urlToNavigateBack);
5857+
InteractionManager.runAfterInteractions(() => {
5858+
// After navigation, update the remaining data.
5859+
Onyx.update(onyxUpdates);
5860+
});
5861+
});
58565862
}
58575863

58585864
/**

0 commit comments

Comments
 (0)