Skip to content

Commit

Permalink
Merge pull request Expensify#43633 from bernhardoj/fix/42692-clears-s…
Browse files Browse the repository at this point in the history
…econdary-login-report

Clear the optimistic secondary login report when there is a preexisting report
  • Loading branch information
dangrous authored Jun 18, 2024
2 parents abc9882 + 3d4b4f7 commit 9db5062
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1279,10 +1279,14 @@ function handleReportChanged(report: OnyxEntry<Report>) {
// 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 ?? '-1'), CONST.NAVIGATION.TYPE.UP);
};
}
Expand Down

0 comments on commit 9db5062

Please sign in to comment.