Skip to content

Commit 1e57f28

Browse files
authored
Merge pull request Expensify#78823 from daledah/fix/78133-follow-up
fix: app opens Inbox after refreshing Reports page with Split RHP opened
2 parents e61f813 + 6db9705 commit 1e57f28

7 files changed

Lines changed: 62 additions & 7 deletions

File tree

src/ROUTES.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,19 @@ const ROUTES = {
772772
return getUrlWithBackToParam(`create/split-expense/overview/${reportID}/${originalTransactionID}${splitExpenseTransactionIDPart}`, backTo);
773773
},
774774
},
775+
SPLIT_EXPENSE_SEARCH: {
776+
route: 'create/split-expense/overview/:reportID/:transactionID/:splitExpenseTransactionID/search/:backTo?',
777+
getRoute: (reportID: string | undefined, originalTransactionID: string | undefined, splitExpenseTransactionID?: string, backTo?: string) => {
778+
if (!reportID || !originalTransactionID) {
779+
Log.warn(`Invalid ${reportID}(reportID) or ${originalTransactionID}(transactionID) is used to build the SPLIT_EXPENSE_SEARCH route`);
780+
}
781+
782+
const splitExpenseTransactionIDPart = splitExpenseTransactionID ? `/${splitExpenseTransactionID}` : '/0';
783+
784+
// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
785+
return getUrlWithBackToParam(`create/split-expense/overview/${reportID}/${originalTransactionID}${splitExpenseTransactionIDPart}/search`, backTo);
786+
},
787+
},
775788
SPLIT_EXPENSE_CREATE_DATE_RANGE: {
776789
route: 'create/split-expense/create-date-range/:reportID/:transactionID?',
777790
getRoute: (reportID: string | undefined, transactionID: string | undefined, backTo?: string) => {

src/SCREENS.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ const SCREENS = {
321321
STEP_REPORT: 'Money_Request_Report',
322322
EDIT_REPORT: 'Money_Request_Edit_Report',
323323
SPLIT_EXPENSE: 'Money_Request_Split_Expense',
324+
SPLIT_EXPENSE_SEARCH: 'Money_Request_Split_Expense_Search',
324325
SPLIT_EXPENSE_CREATE_DATE_RANGE: 'Money_Request_Split_Expense_Create_Date_Range',
325326
SPLIT_EXPENSE_EDIT: 'Money_Request_Split_Expense_Edit',
326327
DISTANCE_CREATE: 'Money_Request_Distance_Create',

src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ const MoneyRequestModalStackNavigator = createModalStackNavigator<MoneyRequestNa
176176
[SCREENS.MONEY_REQUEST.STEP_SUBRATE_EDIT]: () => require<ReactComponentModule>('../../../../pages/iou/request/step/IOURequestStepSubrate').default,
177177
[SCREENS.MONEY_REQUEST.RECEIPT_VIEW]: () => require<ReactComponentModule>('../../../../pages/iou/request/step/IOURequestStepScan/ReceiptView').default,
178178
[SCREENS.MONEY_REQUEST.SPLIT_EXPENSE]: () => require<ReactComponentModule>('../../../../pages/iou/SplitExpensePage').default,
179+
[SCREENS.MONEY_REQUEST.SPLIT_EXPENSE_SEARCH]: () => require<ReactComponentModule>('../../../../pages/iou/SplitExpensePage').default,
179180
[SCREENS.MONEY_REQUEST.SPLIT_EXPENSE_CREATE_DATE_RANGE]: () => require<ReactComponentModule>('../../../../pages/iou/SplitExpenseCreateDateRagePage').default,
180181
[SCREENS.MONEY_REQUEST.SPLIT_EXPENSE_EDIT]: () => require<ReactComponentModule>('../../../../pages/iou/SplitExpenseEditPage').default,
181182
[SCREENS.MONEY_REQUEST.DISTANCE_CREATE]: () => require<ReactComponentModule>('../../../../pages/iou/request/DistanceRequestStartPage').default,

src/libs/Navigation/helpers/getAdaptedStateFromPath.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
4663
function 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 {

src/libs/Navigation/linkingConfig/RELATIONS/SEARCH_TO_RHP.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const SEARCH_TO_RHP: Partial<Record<keyof SearchFullscreenNavigatorParamList, st
4949
SCREENS.SEARCH.ADVANCED_FILTERS_PURCHASE_CURRENCY_RHP,
5050
SCREENS.SEARCH.ADVANCED_FILTERS_REPORT_FIELD_RHP,
5151
SCREENS.SEARCH.SAVED_SEARCH_RENAME_RHP,
52+
SCREENS.MONEY_REQUEST.SPLIT_EXPENSE_SEARCH,
5253
SCREENS.RIGHT_MODAL.SEARCH_REPORT,
5354
],
5455
};

src/libs/Navigation/linkingConfig/config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,21 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
15101510
},
15111511
},
15121512
},
1513+
[SCREENS.MONEY_REQUEST.SPLIT_EXPENSE_SEARCH]: {
1514+
path: ROUTES.SPLIT_EXPENSE_SEARCH.route,
1515+
exact: true,
1516+
screens: {
1517+
[CONST.TAB.SPLIT.AMOUNT]: {
1518+
path: CONST.TAB.SPLIT.AMOUNT,
1519+
},
1520+
[CONST.TAB.SPLIT.PERCENTAGE]: {
1521+
path: CONST.TAB.SPLIT.PERCENTAGE,
1522+
},
1523+
[CONST.TAB.SPLIT.DATE]: {
1524+
path: CONST.TAB.SPLIT.DATE,
1525+
},
1526+
},
1527+
},
15131528
[SCREENS.MONEY_REQUEST.SPLIT_EXPENSE_CREATE_DATE_RANGE]: {
15141529
path: ROUTES.SPLIT_EXPENSE_CREATE_DATE_RANGE.route,
15151530
exact: true,

src/libs/actions/IOU/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13416,8 +13416,11 @@ function initSplitExpense(transactions: OnyxCollection<OnyxTypes.Transaction>, r
1341613416
});
1341713417

1341813418
Onyx.set(`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${originalTransactionID}`, draftTransaction);
13419-
13420-
Navigation.navigate(ROUTES.SPLIT_EXPENSE.getRoute(reportID, originalTransactionID, transaction.transactionID, Navigation.getActiveRoute()));
13419+
if (isSearchTopmostFullScreenRoute()) {
13420+
Navigation.navigate(ROUTES.SPLIT_EXPENSE_SEARCH.getRoute(reportID, originalTransactionID, transaction.transactionID, Navigation.getActiveRoute()));
13421+
} else {
13422+
Navigation.navigate(ROUTES.SPLIT_EXPENSE.getRoute(reportID, originalTransactionID, transaction.transactionID, Navigation.getActiveRoute()));
13423+
}
1342113424
return;
1342213425
}
1342313426

@@ -13446,7 +13449,11 @@ function initSplitExpense(transactions: OnyxCollection<OnyxTypes.Transaction>, r
1344613449

1344713450
Onyx.set(`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transaction?.transactionID}`, draftTransaction);
1344813451

13449-
Navigation.navigate(ROUTES.SPLIT_EXPENSE.getRoute(reportID, transaction.transactionID, undefined, Navigation.getActiveRoute()));
13452+
if (isSearchTopmostFullScreenRoute()) {
13453+
Navigation.navigate(ROUTES.SPLIT_EXPENSE_SEARCH.getRoute(reportID, transaction.transactionID, undefined, Navigation.getActiveRoute()));
13454+
} else {
13455+
Navigation.navigate(ROUTES.SPLIT_EXPENSE.getRoute(reportID, transaction.transactionID, undefined, Navigation.getActiveRoute()));
13456+
}
1345013457
}
1345113458

1345213459
/**

0 commit comments

Comments
 (0)