Skip to content

Commit 8a9fc5c

Browse files
committed
Open child reports in current Search tab
1 parent 34682b6 commit 8a9fc5c

5 files changed

Lines changed: 20 additions & 13 deletions

File tree

src/components/ParentNavigationSubtitle.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,12 @@ 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 && lastRoute?.name === SCREENS.RIGHT_MODAL.EXPENSE_REPORT) {
186-
if (previousRoute.params && 'reportID' in previousRoute.params) {
187-
const reportIDFromParams = previousRoute.params.reportID;
185+
if (previousRoute?.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT && previousRoute.params && 'reportID' in previousRoute.params) {
186+
const reportIDFromParams = previousRoute.params.reportID;
188187

189-
if (reportIDFromParams === parentReportID) {
190-
Navigation.goBack();
191-
return;
192-
}
188+
if (reportIDFromParams === parentReportID) {
189+
Navigation.goBack();
190+
return;
193191
}
194192
}
195193
}

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, shouldRenderTertiaryOverlay} = useWideRHPState();
111+
const {superWideRHPRouteKeys, wideRHPRouteKeys, 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 || isSmallScreenWidth;
136+
const animationEnabledOnSearchReport = superWideRHPRouteKeys.length > 0 || wideRHPRouteKeys.length > 0 || isSmallScreenWidth;
137137

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

src/libs/actions/Report/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ import Log from '@libs/Log';
7979
import {isEmailPublicDomain} from '@libs/LoginUtils';
8080
import {getMovedReportID} from '@libs/ModifiedExpenseMessage';
8181
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
82+
import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute';
8283
import type {LinkToOptions} from '@libs/Navigation/helpers/linkTo/types';
8384
import Navigation from '@libs/Navigation/Navigation';
8485
import enhanceParameters from '@libs/Network/enhanceParameters';
@@ -2150,7 +2151,11 @@ function navigateToAndOpenChildReport(
21502151
) {
21512152
const report = childReport ?? createChildReport(childReport, parentReportAction, parentReport, currentUserAccountID, introSelected, betas, personalDetails);
21522153

2153-
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.reportID, undefined, undefined, Navigation.getActiveRoute()));
2154+
if (isSearchTopmostFullScreenRoute()) {
2155+
Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID: report.reportID, backTo: Navigation.getActiveRoute()}));
2156+
} else {
2157+
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.reportID, undefined, undefined, Navigation.getActiveRoute()));
2158+
}
21542159
}
21552160

21562161
/**

src/pages/inbox/HeaderView.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import SidePanelButton from '@components/SidePanel/SidePanelButton';
2121
import TaskHeaderActionButton from '@components/TaskHeaderActionButton';
2222
import Text from '@components/Text';
2323
import Tooltip from '@components/Tooltip';
24+
import {useWideRHPState} from '@components/WideRHPContextProvider';
2425
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
2526
import useHasTeam2025Pricing from '@hooks/useHasTeam2025Pricing';
2627
import useIsInSidePanel from '@hooks/useIsInSidePanel';
@@ -105,6 +106,8 @@ function HeaderView({onNavigationMenuButtonClicked, reportID}: HeaderViewProps)
105106
const {isSmallScreenWidth, shouldUseNarrowLayout, isInLandscapeMode} = useResponsiveLayout();
106107
const isInSidePanel = useIsInSidePanel();
107108
const route = useRoute();
109+
const {wideRHPRouteKeys, superWideRHPRouteKeys} = useWideRHPState();
110+
const openParentReportInCurrentTab = route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT && (wideRHPRouteKeys.length > 0 || superWideRHPRouteKeys.length > 0);
108111
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(report?.parentReportID) ?? getNonEmptyStringOnyxID(report?.reportID)}`);
109112
const [grandParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(parentReport?.parentReportID)}`);
110113
const grandParentReportAction = useParentReportAction(parentReport);
@@ -346,6 +349,7 @@ function HeaderView({onNavigationMenuButtonClicked, reportID}: HeaderViewProps)
346349
parentReportID={parentNavigationReport?.parentReportID}
347350
parentReportActionID={isParentOneTransactionThread ? undefined : parentNavigationReport?.parentReportActionID}
348351
pressableStyles={[styles.alignSelfStart, styles.mw100]}
352+
openParentReportInCurrentTab={openParentReportInCurrentTab}
349353
humanAgentAccountID={humanAgentAccountID}
350354
humanAgentName={humanAgentName}
351355
/>

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} = 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;
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;
272272
const shouldDelayAutoFocusRef = useRef(shouldDelayAutoFocus);
273273
shouldDelayAutoFocusRef.current = shouldDelayAutoFocus;
274274

0 commit comments

Comments
 (0)