Skip to content

Commit e148704

Browse files
authored
Merge pull request Expensify#79356 from s77rt/preexistingreport-clean-up-iou
PreexistingReport: clear stale IOU action on transaction threads
2 parents f0cdc57 + f7ecd2f commit e148704

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/libs/actions/Report.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ import {
160160
isGroupChat as isGroupChatReportUtils,
161161
isHiddenForCurrentUser,
162162
isIOUReportUsingReport,
163+
isMoneyRequest,
163164
isMoneyRequestReport,
164165
isOpenExpenseReport,
165166
isProcessingReport,
@@ -1892,10 +1893,13 @@ function handlePreexistingReport(report: Report) {
18921893
}
18931894

18941895
// Handle cleanup of stale optimistic IOU report and its report preview separately
1895-
if (isMoneyRequestReport(report) && parentReportActionID) {
1896-
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`, {
1897-
[parentReportActionID]: null,
1898-
});
1896+
if ((isMoneyRequestReport(report) || isMoneyRequest(report)) && parentReportID && parentReportActionID) {
1897+
const parentReportAction = allReportActions?.[parentReportID]?.[parentReportActionID];
1898+
if (parentReportAction?.childReportID === reportID) {
1899+
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`, {
1900+
[parentReportActionID]: null,
1901+
});
1902+
}
18991903
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, null);
19001904
return;
19011905
}

0 commit comments

Comments
 (0)