diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 199240e35266..d11b34d649ef 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1952,15 +1952,6 @@ function leaveRoom(reportID) { ], }, ); - Navigation.dismissModal(); - if (Navigation.getTopmostReportId() === reportID) { - Navigation.goBack(ROUTES.HOME); - } - if (report.parentReportID) { - Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.parentReportID), CONST.NAVIGATION.TYPE.FORCED_UP); - return; - } - navigateToConciergeChat(); } /** diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 7a979ae18783..873d8c4d5079 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -314,7 +314,15 @@ function ReportScreen({ // optimistic case (prevOnyxReportID && prevOnyxReportID === routeReportID && !onyxReportID && prevReport.statusNum === CONST.REPORT.STATUS.OPEN && report.statusNum === CONST.REPORT.STATUS.CLOSED) ) { - Navigation.goBack(); + Navigation.dismissModal(); + if (Navigation.getTopmostReportId() === prevOnyxReportID) { + Navigation.setShouldPopAllStateOnUP(); + Navigation.goBack(ROUTES.HOME, false, true); + } + if (prevReport.parentReportID) { + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(prevReport.parentReportID)); + return; + } Report.navigateToConciergeChat(); return; } @@ -329,7 +337,7 @@ function ReportScreen({ fetchReportIfNeeded(); ComposerActions.setShouldShowComposeInput(true); - }, [route, report, errors, fetchReportIfNeeded, prevReport.reportID, prevUserLeavingStatus, userLeavingStatus, prevReport.statusNum]); + }, [route, report, errors, fetchReportIfNeeded, prevReport.reportID, prevUserLeavingStatus, userLeavingStatus, prevReport.statusNum, prevReport.parentReportID]); useEffect(() => { // Ensures subscription event succeeds when the report/workspace room is created optimistically.