diff --git a/src/libs/Navigation/Navigation.js b/src/libs/Navigation/Navigation.js index 912e7b23b3dc..503d9fc8251a 100644 --- a/src/libs/Navigation/Navigation.js +++ b/src/libs/Navigation/Navigation.js @@ -172,6 +172,11 @@ function dismissModal(targetReportID) { const action = getActionFromState(state, linkingConfig.config); action.type = 'REPLACE'; navigationRef.current.dispatch(action); + // If not-found page is in the route stack, we need to close it + } else if (targetReportID && _.some(rootState.routes, (route) => route.name === SCREENS.NOT_FOUND)) { + const lastRouteIndex = rootState.routes.length - 1; + const centralRouteIndex = _.findLastIndex(rootState.routes, (route) => route.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR); + navigationRef.current.dispatch({...StackActions.pop(lastRouteIndex - centralRouteIndex), target: rootState.key}); } else { navigationRef.current.dispatch({...StackActions.pop(), target: rootState.key}); }