From 7ee0fca5f3e2dfc63921c83eef5afe642347c9ed Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 13 Jun 2024 13:55:31 +0800 Subject: [PATCH] clear the report when there is a preexisting report --- src/libs/actions/Report.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 3adf48046936..ff00d6993d86 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1280,10 +1280,14 @@ function handleReportChanged(report: OnyxEntry) { // In this case, the API will let us know by returning a preexistingReportID. // We should clear out the optimistically created report and re-route the user to the preexisting report. if (report?.reportID && report.preexistingReportID) { - let callback = () => {}; + let callback = () => { + Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, null); + }; // Only re-route them if they are still looking at the optimistically created report if (Navigation.getActiveRoute().includes(`/r/${report.reportID}`)) { + const currCallback = callback; callback = () => { + currCallback(); Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.preexistingReportID ?? ''), CONST.NAVIGATION.TYPE.UP); }; }