diff --git a/src/ROUTES.ts b/src/ROUTES.ts index f4eee3bb7971..9d45934143cb 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -1448,7 +1448,9 @@ const ROUTES = { */ const HYBRID_APP_ROUTES = { MONEY_REQUEST_CREATE: '/request/new/scan', - MONEY_REQUEST_SUBMIT_CREATE: '/submit/new/scan', + MONEY_REQUEST_CREATE_TAB_SCAN: '/submit/new/scan', + MONEY_REQUEST_CREATE_TAB_MANUAL: '/submit/new/manual', + MONEY_REQUEST_CREATE_TAB_DISTANCE: '/submit/new/distance', } as const; export {HYBRID_APP_ROUTES, getUrlWithBackToParam, PUBLIC_SCREENS_ROUTES}; diff --git a/src/libs/Navigation/AppNavigator/index.native.tsx b/src/libs/Navigation/AppNavigator/index.native.tsx index 984ed8a2e46f..159626a45df4 100644 --- a/src/libs/Navigation/AppNavigator/index.native.tsx +++ b/src/libs/Navigation/AppNavigator/index.native.tsx @@ -10,7 +10,7 @@ type AppNavigatorProps = { }; function AppNavigator({authenticated}: AppNavigatorProps) { - const {initialURL} = useContext(InitialURLContext); + const {initialURL, setInitialURL} = useContext(InitialURLContext); useEffect(() => { if (!NativeModules.HybridAppModule || !initialURL) { @@ -18,9 +18,10 @@ function AppNavigator({authenticated}: AppNavigatorProps) { } Navigation.isNavigationReady().then(() => { - Navigation.navigate(initialURL); + Navigation.navigate(Navigation.parseHybridAppUrl(initialURL)); + setInitialURL(undefined); }); - }, [initialURL]); + }, [initialURL, setInitialURL]); if (authenticated) { const AuthScreens = require('./AuthScreens').default; diff --git a/src/libs/Navigation/AppNavigator/index.tsx b/src/libs/Navigation/AppNavigator/index.tsx index 1901a51563e9..05961528ca11 100644 --- a/src/libs/Navigation/AppNavigator/index.tsx +++ b/src/libs/Navigation/AppNavigator/index.tsx @@ -1,8 +1,4 @@ -import React, {lazy, memo, Suspense, useContext, useEffect} from 'react'; -import {NativeModules} from 'react-native'; -import {InitialURLContext} from '@components/InitialURLContextProvider'; -import Navigation from '@libs/Navigation/Navigation'; -import ROUTES from '@src/ROUTES'; +import React, {lazy, memo, Suspense} from 'react'; import lazyRetry from '@src/utils/lazyRetry'; const AuthScreens = lazy(() => lazyRetry(() => import('./AuthScreens'))); @@ -14,18 +10,6 @@ type AppNavigatorProps = { }; function AppNavigator({authenticated}: AppNavigatorProps) { - const {initialURL} = useContext(InitialURLContext); - - useEffect(() => { - if (!NativeModules.HybridAppModule || !initialURL || !initialURL.includes(ROUTES.TRANSITION_BETWEEN_APPS)) { - return; - } - - Navigation.isNavigationReady().then(() => { - Navigation.navigate(initialURL); - }); - }, [initialURL]); - if (authenticated) { // These are the protected screens and only accessible when an authToken is present return ( diff --git a/src/libs/Navigation/Navigation.ts b/src/libs/Navigation/Navigation.ts index 4bd86503fd2b..4c61b953f572 100644 --- a/src/libs/Navigation/Navigation.ts +++ b/src/libs/Navigation/Navigation.ts @@ -102,9 +102,13 @@ function getActiveRouteIndex(stateOrRoute: StateOrRoute, index?: number): number */ function parseHybridAppUrl(url: HybridAppRoute | Route): Route { switch (url) { + case HYBRID_APP_ROUTES.MONEY_REQUEST_CREATE_TAB_MANUAL: + return ROUTES.MONEY_REQUEST_CREATE_TAB_MANUAL.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.SUBMIT, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, ReportUtils.generateReportID()); + case HYBRID_APP_ROUTES.MONEY_REQUEST_CREATE_TAB_DISTANCE: + return ROUTES.MONEY_REQUEST_CREATE_TAB_DISTANCE.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.SUBMIT, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, ReportUtils.generateReportID()); case HYBRID_APP_ROUTES.MONEY_REQUEST_CREATE: - case HYBRID_APP_ROUTES.MONEY_REQUEST_SUBMIT_CREATE: - return ROUTES.MONEY_REQUEST_CREATE.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.SUBMIT, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, ReportUtils.generateReportID()); + case HYBRID_APP_ROUTES.MONEY_REQUEST_CREATE_TAB_SCAN: + return ROUTES.MONEY_REQUEST_CREATE_TAB_SCAN.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.SUBMIT, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, ReportUtils.generateReportID()); default: return url; }