@@ -43,6 +43,23 @@ function isRouteWithReportID(route: NavigationPartialRoute): route is Route<stri
4343 return route . params !== undefined && 'reportID' in route . params && typeof route . params . reportID === 'string' ;
4444}
4545
46+ /**
47+ * Get the appropriate screen name for RHP_TO_SEARCH lookup.
48+ * Split tabs (amount, percentage, date) are nested routes within SPLIT_EXPENSE/SPLIT_EXPENSE_SEARCH.
49+ * When a split tab route is accessed from search context (path contains '/search'),
50+ * we use SPLIT_EXPENSE_SEARCH for the mapping lookup instead of the tab name.
51+ */
52+ function getSearchScreenNameForRoute ( route : NavigationPartialRoute ) : string {
53+ const splitTabNames = Object . values ( CONST . TAB . SPLIT ) as string [ ] ;
54+ const isSplitTabRoute = splitTabNames . includes ( route . name ) ;
55+
56+ if ( isSplitTabRoute && route . path ?. includes ( '/search' ) ) {
57+ return SCREENS . MONEY_REQUEST . SPLIT_EXPENSE_SEARCH ;
58+ }
59+
60+ return route . name ;
61+ }
62+
4663function getMatchingFullScreenRoute ( route : NavigationPartialRoute ) {
4764 // Check for backTo param. One screen with different backTo value may need different screens visible under the overlay.
4865 if ( isRouteWithBackToParam ( route ) ) {
@@ -69,11 +86,11 @@ function getMatchingFullScreenRoute(route: NavigationPartialRoute) {
6986 // If not, get the matching full screen route for the back to state.
7087 return getMatchingFullScreenRoute ( focusedStateForBackToRoute ) ;
7188 }
72-
73- if ( RHP_TO_SEARCH [ route . name ] ) {
74- const paramsFromRoute = getParamsFromRoute ( RHP_TO_SEARCH [ route . name ] ) ;
89+ const routeNameForLookup = getSearchScreenNameForRoute ( route ) ;
90+ if ( RHP_TO_SEARCH [ routeNameForLookup ] ) {
91+ const paramsFromRoute = getParamsFromRoute ( RHP_TO_SEARCH [ routeNameForLookup ] ) ;
7592 const searchRoute = {
76- name : RHP_TO_SEARCH [ route . name ] ,
93+ name : RHP_TO_SEARCH [ routeNameForLookup ] ,
7794 params : paramsFromRoute . length > 0 ? pick ( route . params , paramsFromRoute ) : undefined ,
7895 } ;
7996 return {
0 commit comments