Skip to content

Commit cf14728

Browse files
authored
Merge pull request #90183 from Expensify/revert-88527-fix/open-report-thread-in-rhp
[CP Staging] Revert "Navigate to report thread in RHP when viewing a report in a right docked modal"
2 parents da39605 + 1ff959d commit cf14728

9 files changed

Lines changed: 34 additions & 156 deletions

File tree

src/components/ParentNavigationSubtitle.tsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -182,22 +182,16 @@ function ParentNavigationSubtitle({
182182
// avoid stacking RHPs by going back to the search report if it's already there
183183
const previousRoute = currentFocusedNavigator?.state?.routes.at(-2);
184184

185-
if (previousRoute?.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT && previousRoute.params && 'reportID' in previousRoute.params) {
186-
const reportIDFromParams = previousRoute.params.reportID;
185+
if (previousRoute?.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT && lastRoute?.name === SCREENS.RIGHT_MODAL.EXPENSE_REPORT) {
186+
if (previousRoute.params && 'reportID' in previousRoute.params) {
187+
const reportIDFromParams = previousRoute.params.reportID;
187188

188-
if (reportIDFromParams === parentReportID) {
189-
Navigation.goBack();
190-
return;
189+
if (reportIDFromParams === parentReportID) {
190+
Navigation.goBack();
191+
return;
192+
}
191193
}
192194
}
193-
194-
// Stay in the Search tab when the parent link is tapped from a SEARCH_REPORT RHP
195-
// and the parent isn't already in the stack — otherwise the REPORT_WITH_ID fallback
196-
// would yank the user to Inbox.
197-
if (isReportInRHP) {
198-
Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID: parentReportID, reportActionID: isVisibleAction ? parentReportActionID : undefined}));
199-
return;
200-
}
201195
}
202196

203197
// If the parent report is already the previous screen in the main stack, go back to it

src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) {
108108
const containerRef = useRef(null);
109109
const isExecutingRef = useRef<boolean>(false);
110110
const screenOptions = useRHPScreenOptions();
111-
const {superWideRHPRouteKeys, wideRHPRouteKeys, shouldRenderTertiaryOverlay} = useWideRHPState();
111+
const {superWideRHPRouteKeys, shouldRenderTertiaryOverlay} = useWideRHPState();
112112
const {clearWideRHPKeys, syncRHPKeys} = useWideRHPActions();
113113
const {windowWidth} = useWindowDimensions();
114114
const modalStackScreenOptions = useModalStackScreenOptions();
@@ -133,7 +133,7 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) {
133133

134134
// Animation should be disabled when we open the wide rhp from the narrow one.
135135
// When the wide rhp page is opened as first one, it will be animated with the entire RightModalNavigator.
136-
const animationEnabledOnSearchReport = superWideRHPRouteKeys.length > 0 || wideRHPRouteKeys.length > 0 || isSmallScreenWidth;
136+
const animationEnabledOnSearchReport = superWideRHPRouteKeys.length > 0 || isSmallScreenWidth;
137137

138138
const animatedWidth = expandedRHPProgress.interpolate({
139139
inputRange: [0, 1, 2],

src/libs/Navigation/helpers/getTopmostFullScreenRoute.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
import {navigationRef} from '@libs/Navigation/Navigation';
2+
import type {RootNavigatorParamList, State} from '@libs/Navigation/types';
13
import NAVIGATORS from '@src/NAVIGATORS';
2-
import getTopmostFullScreenRoute from './getTopmostFullScreenRoute';
4+
import getActiveTabName from './getActiveTabName';
5+
import {isFullScreenName} from './isNavigatorName';
36

47
const isReportTopmostSplitNavigator = (): boolean => {
5-
const topmostFullScreenRoute = getTopmostFullScreenRoute();
6-
if (!topmostFullScreenRoute) {
8+
const rootState = navigationRef.getRootState() as State<RootNavigatorParamList>;
9+
10+
if (!rootState) {
711
return false;
812
}
9-
return topmostFullScreenRoute.name === NAVIGATORS.REPORTS_SPLIT_NAVIGATOR;
13+
14+
const topmostFullScreenRoute = rootState.routes.findLast((route) => isFullScreenName(route.name));
15+
return getActiveTabName(topmostFullScreenRoute) === NAVIGATORS.REPORTS_SPLIT_NAVIGATOR;
1016
};
1117

1218
export default isReportTopmostSplitNavigator;
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
import {navigationRef} from '@libs/Navigation/Navigation';
2+
import type {RootNavigatorParamList, State} from '@libs/Navigation/types';
13
import NAVIGATORS from '@src/NAVIGATORS';
2-
import getTopmostFullScreenRoute from './getTopmostFullScreenRoute';
4+
import getActiveTabName from './getActiveTabName';
5+
import {isFullScreenName} from './isNavigatorName';
36

47
const isSearchTopmostFullScreenRoute = (): boolean => {
5-
const topmostFullScreenRoute = getTopmostFullScreenRoute();
6-
if (!topmostFullScreenRoute) {
8+
const rootState = navigationRef.getRootState() as State<RootNavigatorParamList>;
9+
10+
if (!rootState) {
711
return false;
812
}
9-
return topmostFullScreenRoute.name === NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR;
13+
14+
const topmostFullScreenRoute = rootState.routes.findLast((route) => isFullScreenName(route.name));
15+
return getActiveTabName(topmostFullScreenRoute) === NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR;
1016
};
1117

1218
export default isSearchTopmostFullScreenRoute;

src/libs/actions/Report/index.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ import Log from '@libs/Log';
8080
import {isEmailPublicDomain} from '@libs/LoginUtils';
8181
import {getMovedReportID} from '@libs/ModifiedExpenseMessage';
8282
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
83-
import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute';
8483
import type {LinkToOptions} from '@libs/Navigation/helpers/linkTo/types';
8584
import Navigation from '@libs/Navigation/Navigation';
8685
import enhanceParameters from '@libs/Network/enhanceParameters';
@@ -2374,11 +2373,7 @@ function navigateToAndOpenChildReport(
23742373
) {
23752374
const report = childReport ?? createChildReport(childReport, parentReportAction, parentReport, currentUserAccountID, introSelected, betas, isSelfTourViewed, personalDetails);
23762375

2377-
if (isSearchTopmostFullScreenRoute()) {
2378-
Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID: report.reportID, backTo: Navigation.getActiveRoute()}));
2379-
} else {
2380-
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.reportID, undefined, undefined, Navigation.getActiveRoute()));
2381-
}
2376+
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.reportID, undefined, undefined, Navigation.getActiveRoute()));
23822377
}
23832378

23842379
/**
@@ -2471,11 +2466,7 @@ function explain(
24712466
// Check if explanation thread report already exists
24722467
const report = childReport ?? createChildReport(childReport, reportAction, originalReport, currentUserAccountID, introSelected, betas, isSelfTourViewed);
24732468

2474-
if (isSearchTopmostFullScreenRoute()) {
2475-
Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID: report.reportID, backTo: Navigation.getActiveRoute()}));
2476-
} else {
2477-
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.reportID, undefined, undefined, Navigation.getActiveRoute()));
2478-
}
2469+
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.reportID, undefined, undefined, Navigation.getActiveRoute()));
24792470
// Schedule adding the explanation comment on the next animation frame
24802471
// so it runs immediately after navigation completes.
24812472
requestAnimationFrame(() => {

src/pages/inbox/HeaderView.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ function HeaderView({onNavigationMenuButtonClicked, reportID}: HeaderViewProps)
105105
const {isSmallScreenWidth, shouldUseNarrowLayout, isInLandscapeMode} = useResponsiveLayout();
106106
const isInSidePanel = useIsInSidePanel();
107107
const route = useRoute();
108-
const openParentReportInCurrentTab = route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT;
109108
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(report?.parentReportID) ?? getNonEmptyStringOnyxID(report?.reportID)}`);
110109
const [grandParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(parentReport?.parentReportID)}`);
111110
const grandParentReportAction = useParentReportAction(parentReport);
@@ -347,7 +346,6 @@ function HeaderView({onNavigationMenuButtonClicked, reportID}: HeaderViewProps)
347346
parentReportID={parentNavigationReport?.parentReportID}
348347
parentReportActionID={isParentOneTransactionThread ? undefined : parentNavigationReport?.parentReportActionID}
349348
pressableStyles={[styles.alignSelfStart, styles.mw100]}
350-
openParentReportInCurrentTab={openParentReportInCurrentTab}
351349
humanAgentAccountID={humanAgentAccountID}
352350
humanAgentName={humanAgentName}
353351
/>

src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ function ComposerWithSuggestions({
266266

267267
const commentRef = useRef(value);
268268

269-
const {superWideRHPRouteKeys, wideRHPRouteKeys} = useWideRHPState();
270-
// When SearchReport is stacked above another RHP (wide or super-wide), delay autofocus until after the transition completes to avoid animation jank
271-
const shouldDelayAutoFocus = (superWideRHPRouteKeys.length > 0 || wideRHPRouteKeys.length > 0) && route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT;
269+
const {superWideRHPRouteKeys} = useWideRHPState();
270+
// When SearchReport is stacked above another RHP, delay autofocus until after the transition completes to avoid animation jank
271+
const shouldDelayAutoFocus = superWideRHPRouteKeys.length > 0 && route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT;
272272
const shouldDelayAutoFocusRef = useRef(shouldDelayAutoFocus);
273273
shouldDelayAutoFocusRef.current = shouldDelayAutoFocus;
274274

tests/unit/Navigation/getTopmostFullScreenRouteTest.ts

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)