Skip to content

Commit 41d1cdd

Browse files
committed
Dismiss wide report from AuthScreens
1 parent 185e5ad commit 41d1cdd

5 files changed

Lines changed: 15 additions & 28 deletions

File tree

src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {FullScreenContextProvider} from './components/VideoPlayerContexts/FullSc
3838
import {PlaybackContextProvider} from './components/VideoPlayerContexts/PlaybackContext';
3939
import {VideoPopoverMenuContextProvider} from './components/VideoPlayerContexts/VideoPopoverMenuContext';
4040
import {VolumeContextProvider} from './components/VideoPlayerContexts/VolumeContext';
41+
import WideRHPContextProvider from './components/WideRHPContextProvider';
4142
import {KeyboardStateProvider} from './components/withKeyboardState';
4243
import CONFIG from './CONFIG';
4344
import CONST from './CONST';
@@ -125,6 +126,7 @@ function App() {
125126
SidePanelContextProvider,
126127
ExpensifyCardContextProvider,
127128
KYCWallContextProvider,
129+
WideRHPContextProvider,
128130
]}
129131
>
130132
<CustomStatusBarAndBackground />

src/libs/Navigation/AppNavigator/AuthScreens.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type {RouteProp} from '@react-navigation/native';
2-
import {StackActions, useNavigation} from '@react-navigation/native';
32
import type {StackCardInterpolationProps} from '@react-navigation/stack';
43
import React, {memo, useContext, useEffect, useMemo, useRef, useState} from 'react';
54
import ComposeProviders from '@components/ComposeProviders';
@@ -13,7 +12,7 @@ import {SearchContextProvider} from '@components/Search/SearchContext';
1312
import {useSearchRouterContext} from '@components/Search/SearchRouter/SearchRouterContext';
1413
import SearchRouterModal from '@components/Search/SearchRouter/SearchRouterModal';
1514
import SupportalPermissionDeniedModalProvider from '@components/SupportalPermissionDeniedModalProvider';
16-
import WideRHPContextProvider from '@components/WideRHPContextProvider';
15+
import {WideRHPContext} from '@components/WideRHPContextProvider';
1716
import useAutoUpdateTimezone from '@hooks/useAutoUpdateTimezone';
1817
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
1918
import useOnboardingFlowRouter from '@hooks/useOnboardingFlow';
@@ -158,6 +157,7 @@ function AuthScreens() {
158157
const prevIsOnboardingLoading = usePrevious(isOnboardingLoading);
159158
const {initialURL, isAuthenticatedAtStartup, setIsAuthenticatedAtStartup} = useContext(InitialURLContext);
160159
const modalCardStyleInterpolator = useModalCardStyleInterpolator();
160+
const {shouldRenderSecondaryOverlay, dismissToWideReport} = useContext(WideRHPContext);
161161

162162
// State to track whether the delegator's authentication is completed before displaying data
163163
const [isDelegatorFromOldDotIsReady, setIsDelegatorFromOldDotIsReady] = useState(false);
@@ -357,6 +357,11 @@ function AuthScreens() {
357357
return;
358358
}
359359

360+
if (shouldRenderSecondaryOverlay) {
361+
dismissToWideReport();
362+
return;
363+
}
364+
360365
Navigation.dismissModal();
361366
},
362367
shortcutConfig.descriptionKey,
@@ -365,7 +370,7 @@ function AuthScreens() {
365370
true,
366371
);
367372
return () => unsubscribeEscapeKey();
368-
}, [modal?.disableDismissOnEscape, modal?.willAlertModalBecomeVisible]);
373+
}, [dismissToWideReport, modal?.disableDismissOnEscape, modal?.willAlertModalBecomeVisible, shouldRenderSecondaryOverlay]);
369374

370375
// Animation is disabled when navigating to the sidebar screen
371376
const getWorkspaceSplitNavigatorOptions = ({route}: {route: RouteProp<AuthScreensParamList>}) => {
@@ -479,7 +484,6 @@ function AuthScreens() {
479484
LockedAccountModalProvider,
480485
DelegateNoAccessModalProvider,
481486
SupportalPermissionDeniedModalProvider,
482-
WideRHPContextProvider,
483487
]}
484488
>
485489
<RootStack.Navigator

src/libs/Navigation/AppNavigator/createRootStackNavigator/GetStateForActionHandlers.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type {RouterConfigOptions, StackActionType, StackNavigationState} from '@react-navigation/native';
2-
import {CommonActions, StackActions} from '@react-navigation/native';
1+
import type {CommonActions, RouterConfigOptions, StackActionType, StackNavigationState} from '@react-navigation/native';
2+
import {StackActions} from '@react-navigation/native';
33
import type {ParamListBase, Router} from '@react-navigation/routers';
44
import SCREENS_WITH_NAVIGATION_TAB_BAR from '@components/Navigation/TopLevelNavigationTabBar/SCREENS_WITH_NAVIGATION_TAB_BAR';
55
import getIsNarrowLayout from '@libs/getIsNarrowLayout';
@@ -146,32 +146,13 @@ function handleDismissModalAction(
146146
stackRouter: Router<StackNavigationState<ParamListBase>, CommonActions.Action | StackActionType>,
147147
) {
148148
const lastRoute = state.routes.at(-1);
149+
const newAction = StackActions.pop();
149150

150151
if (!lastRoute?.name || !MODAL_ROUTES_TO_DISMISS.includes(lastRoute?.name)) {
151152
Log.hmmm('[Navigation] dismissModal failed because there is no modal stack to dismiss');
152153
return null;
153154
}
154155

155-
if (lastRoute?.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR && lastRoute?.state) {
156-
const rhpRoutes = lastRoute?.state?.routes;
157-
// This handles closing the modal when wide rhp is visible
158-
const wideRhpIndex = rhpRoutes.findLastIndex((rhpRoute) => rhpRoute.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT);
159-
if (wideRhpIndex > -1 && wideRhpIndex !== rhpRoutes.length - 1) {
160-
const modifiedRhp = {
161-
...lastRoute,
162-
state: {
163-
...lastRoute.state,
164-
index: wideRhpIndex,
165-
routes: lastRoute.state.routes.slice(0, wideRhpIndex + 1),
166-
history: lastRoute.state.history?.slice(0, wideRhpIndex + 1),
167-
},
168-
};
169-
const modifiedState = {...state, routes: [...state.routes.slice(0, -1), modifiedRhp]};
170-
const action = CommonActions.reset(modifiedState);
171-
return stackRouter.getStateForAction(state, action, configOptions);
172-
}
173-
}
174-
const newAction = StackActions.pop();
175156
return stackRouter.getStateForAction(state, newAction, configOptions);
176157
}
177158

src/libs/actions/IOU.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ function dismissModalAndOpenReportInInboxTab(reportID?: string) {
934934
// When a report with one expense is opened in the wide RHP and the user adds another expense, RHP should be dismissed and ROUTES.SEARCH_MONEY_REQUEST_REPORT should be displayed.
935935
if (hasMultipleTransactions && reportID) {
936936
Navigation.dismissModal();
937-
// eslint-disable-next-line deprecation/deprecation
937+
// eslint-disable-next-line @typescript-eslint/no-deprecated
938938
InteractionManager.runAfterInteractions(() => {
939939
Navigation.navigate(ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID}));
940940
});

src/pages/iou/request/step/DiscardChangesConfirmation/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function DiscardChangesConfirmation({getHasUnsavedChanges, onCancel}: DiscardCha
6969
cancelText={translate('common.cancel')}
7070
onConfirm={() => {
7171
setIsVisible(false);
72-
// eslint-disable-next-line deprecation/deprecation
72+
// eslint-disable-next-line @typescript-eslint/no-deprecated
7373
InteractionManager.runAfterInteractions(() => {
7474
if (blockedNavigationAction.current) {
7575
navigationRef.current?.dispatch(blockedNavigationAction.current);

0 commit comments

Comments
 (0)