From e7bbab5c877677c4113931be99566c2479ade50d Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Thu, 23 Oct 2025 10:44:27 +0200 Subject: [PATCH 01/64] Move SCREENS.SEARCH.MONEY_REQUEST_REPORT to RHP --- src/components/MoneyReportHeader.tsx | 4 ++-- .../AppNavigator/ModalStackNavigators/index.tsx | 1 + .../Navigators/SearchFullscreenNavigator.tsx | 5 ----- .../linkingConfig/RELATIONS/SEARCH_TO_RHP.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 4 +--- src/libs/Navigation/types.ts | 10 +++++----- src/pages/Search/SearchMoneyRequestReportPage.tsx | 4 ++-- 7 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 15e0ad8d7679..b3c2ce52577f 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -40,7 +40,7 @@ import Log from '@libs/Log'; import {getThreadReportIDsForTransactions, getTotalAmountForIOUReportPreviewButton} from '@libs/MoneyRequestReportUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types'; -import type {ReportsSplitNavigatorParamList, SearchFullscreenNavigatorParamList, SearchReportParamList} from '@libs/Navigation/types'; +import type {ReportsSplitNavigatorParamList, SearchReportParamList} from '@libs/Navigation/types'; import {buildOptimisticNextStepForPreventSelfApprovalsEnabled, buildOptimisticNextStepForStrictPolicyRuleViolations} from '@libs/NextStepUtils'; import type {KYCFlowEvent, TriggerKYCFlow} from '@libs/PaymentUtils'; import {selectPaymentType} from '@libs/PaymentUtils'; @@ -183,7 +183,7 @@ function MoneyReportHeader({ const shouldDisplayNarrowVersion = shouldUseNarrowLayout || isMediumScreenWidth; const route = useRoute< | PlatformStackRouteProp - | PlatformStackRouteProp + | PlatformStackRouteProp | PlatformStackRouteProp >(); const {login: currentUserLogin, accountID, email} = useCurrentUserPersonalDetails(); diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index ae3fb6eb55b4..68b999b00c54 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -833,6 +833,7 @@ const SearchReportModalStackNavigator = createModalStackNavigator require('../../../../pages/Search/SearchHoldReasonPage').default, [SCREENS.SEARCH.TRANSACTION_HOLD_REASON_RHP]: () => require('../../../../pages/Search/SearchHoldReasonPage').default, [SCREENS.SEARCH.TRANSACTIONS_CHANGE_REPORT_SEARCH_RHP]: () => require('../../../../pages/Search/SearchTransactionsChangeReport').default, + [SCREENS.SEARCH.MONEY_REQUEST_REPORT]: () => require('../../../../pages/Search/SearchMoneyRequestReportPage').default, }); const SearchAdvancedFiltersModalStackNavigator = createModalStackNavigator({ diff --git a/src/libs/Navigation/AppNavigator/Navigators/SearchFullscreenNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/SearchFullscreenNavigator.tsx index 437208bd36db..f988fae0a49e 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/SearchFullscreenNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/SearchFullscreenNavigator.tsx @@ -12,7 +12,6 @@ import SCREENS from '@src/SCREENS'; import type ReactComponentModule from '@src/types/utils/ReactComponentModule'; const loadSearchPage = () => require('@pages/Search/SearchPage').default; -const loadSearchMoneyReportPage = () => require('@pages/Search/SearchMoneyRequestReportPage').default; const Stack = createSearchFullscreenNavigator(); @@ -36,10 +35,6 @@ function SearchFullscreenNavigator({route}: PlatformStackScreenProps - ); diff --git a/src/libs/Navigation/linkingConfig/RELATIONS/SEARCH_TO_RHP.ts b/src/libs/Navigation/linkingConfig/RELATIONS/SEARCH_TO_RHP.ts index 2489d81fbf72..92f83f850fde 100644 --- a/src/libs/Navigation/linkingConfig/RELATIONS/SEARCH_TO_RHP.ts +++ b/src/libs/Navigation/linkingConfig/RELATIONS/SEARCH_TO_RHP.ts @@ -46,6 +46,7 @@ const SEARCH_TO_RHP: Partial['config'] = { [SCREENS.RIGHT_MODAL.SEARCH_REPORT]: { screens: { [SCREENS.SEARCH.REPORT_RHP]: ROUTES.SEARCH_REPORT.route, + [SCREENS.SEARCH.MONEY_REQUEST_REPORT]: ROUTES.SEARCH_MONEY_REQUEST_REPORT.route, [SCREENS.SEARCH.MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS]: ROUTES.SEARCH_MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS.route, [SCREENS.SEARCH.TRANSACTION_HOLD_REASON_RHP]: ROUTES.TRANSACTION_HOLD_REASON_RHP, [SCREENS.SEARCH.TRANSACTIONS_CHANGE_REPORT_SEARCH_RHP]: ROUTES.MOVE_TRANSACTIONS_SEARCH_RHP, @@ -1834,9 +1835,6 @@ const config: LinkingOptions['config'] = { [SCREENS.SEARCH.ROOT]: { path: ROUTES.SEARCH_ROOT.route, }, - [SCREENS.SEARCH.MONEY_REQUEST_REPORT]: { - path: ROUTES.SEARCH_MONEY_REQUEST_REPORT.route, - }, }, }, [NAVIGATORS.SHARE_MODAL_NAVIGATOR]: { diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 8b43df571378..7beb4293c098 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -2558,6 +2558,11 @@ type SearchReportParamList = { /** Selected transactions' report ID */ reportID: string; }; + [SCREENS.SEARCH.MONEY_REQUEST_REPORT]: { + reportID: string; + // eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md + backTo?: Routes; + }; }; type SearchFullscreenNavigatorParamList = { @@ -2566,11 +2571,6 @@ type SearchFullscreenNavigatorParamList = { name?: string; groupBy?: string; }; - [SCREENS.SEARCH.MONEY_REQUEST_REPORT]: { - reportID: string; - // eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md - backTo?: Routes; - }; }; type SearchAdvancedFiltersParamList = { diff --git a/src/pages/Search/SearchMoneyRequestReportPage.tsx b/src/pages/Search/SearchMoneyRequestReportPage.tsx index c20ef96f56a2..b8024ce803e7 100644 --- a/src/pages/Search/SearchMoneyRequestReportPage.tsx +++ b/src/pages/Search/SearchMoneyRequestReportPage.tsx @@ -18,7 +18,7 @@ import useTransactionsAndViolationsForReport from '@hooks/useTransactionsAndViol import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID'; import {getAllNonDeletedTransactions} from '@libs/MoneyRequestReportUtils'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; -import type {SearchFullscreenNavigatorParamList} from '@libs/Navigation/types'; +import type {SearchReportParamList} from '@libs/Navigation/types'; import {getFilteredReportActionsForReportView, getIOUActionForTransactionID, getOneTransactionThreadReportID} from '@libs/ReportActionsUtils'; import {isValidReportIDFromPath} from '@libs/ReportUtils'; import Navigation from '@navigation/Navigation'; @@ -32,7 +32,7 @@ import type SCREENS from '@src/SCREENS'; import type {Policy} from '@src/types/onyx'; import {getEmptyObject} from '@src/types/utils/EmptyObject'; -type SearchMoneyRequestPageProps = PlatformStackScreenProps; +type SearchMoneyRequestPageProps = PlatformStackScreenProps; const defaultReportMetadata = { isLoadingInitialReportActions: true, From 11f5d949dc7fecf56bd88831f405aa2da98b7a9b Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Tue, 28 Oct 2025 08:47:40 +0100 Subject: [PATCH 02/64] Add SuperWideRHP --- src/SCREENS.ts | 1 + .../WideRHPContextProvider/index.tsx | 133 ++++++++++++++++-- .../WideRHPContextProvider/types.ts | 15 +- .../ModalStackNavigators/index.tsx | 5 + .../useModalStackScreenOptions.ts | 14 +- .../Navigators/RightModalNavigator.tsx | 34 ++++- .../useRootNavigatorScreenOptions.ts | 6 +- src/libs/Navigation/linkingConfig/config.ts | 6 +- src/libs/Navigation/types.ts | 5 + .../Search/SearchMoneyRequestReportPage.tsx | 6 + src/styles/index.ts | 17 ++- 11 files changed, 213 insertions(+), 29 deletions(-) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index c669b6f24988..117cc4db0353 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -239,6 +239,7 @@ const SCREENS = { TRANSACTION_DUPLICATE: 'TransactionDuplicate', TRAVEL: 'Travel', SEARCH_REPORT: 'SearchReport', + SEARCH_MONEY_REQUEST_REPORT: 'SearchMoneyRequestReport', SEARCH_ADVANCED_FILTERS: 'SearchAdvancedFilters', SEARCH_SAVED_SEARCH: 'SearchSavedSearch', SETTINGS_CATEGORIES: 'SettingsCategories', diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 17410a4520e6..c73440625197 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -1,10 +1,11 @@ -import {findFocusedRoute, StackActions, useNavigation, useRoute} from '@react-navigation/native'; import type {NavigationState, PartialState} from '@react-navigation/native'; +import {findFocusedRoute, StackActions, useNavigation, useRoute} from '@react-navigation/native'; import React, {createContext, useCallback, useContext, useEffect, useMemo, useState} from 'react'; // We use Animated for all functionality related to wide RHP to make it easier // to interact with react-navigation components (e.g., CardContainer, interpolator), which also use Animated. // eslint-disable-next-line no-restricted-imports import {Animated, Dimensions, InteractionManager} from 'react-native'; +import {useSharedValue} from 'react-native-reanimated'; import useRootNavigationState from '@hooks/useRootNavigationState'; import {isFullScreenName} from '@libs/Navigation/helpers/isNavigatorName'; import navigationRef from '@libs/Navigation/navigationRef'; @@ -16,8 +17,8 @@ import defaultWideRHPContextValue from './default'; import type {WideRHPContextType} from './types'; // 0 is folded/hidden, 1 is expanded/shown -const expandedRHPProgress = new Animated.Value(0); const secondOverlayProgress = new Animated.Value(0); +const thirdOverlayProgress = new Animated.Value(0); const wideRHPMaxWidth = variables.receiptPaneRHPMaxWidth + variables.sideBarWidth; @@ -78,9 +79,13 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { // We have a separate containers for allWideRHPRouteKeys and wideRHPRouteKeys because we may have two or more RHPs on the stack. // For convenience and proper overlay logic wideRHPRouteKeys will show only the keys existing in the last RHP. const [allWideRHPRouteKeys, setAllWideRHPRouteKeys] = useState([]); + const [superWideRHPRouteKeys, setSuperWideRHPRouteKeys] = useState([]); const [shouldRenderSecondaryOverlay, setShouldRenderSecondaryOverlay] = useState(false); + const [shouldRenderThirdOverlay, setShouldRenderThirdOverlay] = useState(false); const [expenseReportIDs, setExpenseReportIDs] = useState>(new Set()); + const expandedRHPProgress = useSharedValue(0); + // Return undefined if RHP is not the last route const lastVisibleRHPRouteKey = useRootNavigationState((state) => { // Safe handling when navigation is not yet initialized @@ -143,6 +148,28 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { return false; }); + const shouldShowThirdOverlay = useRootNavigationState((state) => { + // Safe handling when navigation is not yet initialized + if (!state) { + return false; + } + + const focusedRoute = findFocusedRoute(state); + const isRHPLastRootRoute = state?.routes.at(-1)?.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR; + + // Shouldn't ever happen but for type safety + if (!focusedRoute?.key) { + return false; + } + + // Check the focused route to avoid glitching when quickly close and open RHP. + if (superWideRHPRouteKeys.length > 0 && !superWideRHPRouteKeys.includes(focusedRoute.key) && isRHPLastRootRoute && focusedRoute.name !== SCREENS.SEARCH.MONEY_REQUEST_REPORT) { + return true; + } + + return false; + }); + /** * Adds a route to the wide RHP route keys list, enabling wide RHP display for that route. */ @@ -158,6 +185,18 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { setAllWideRHPRouteKeys((prev) => (prev.includes(newKey) ? prev : [newKey, ...prev])); }, []); + const showSuperWideRHPVersion = useCallback((route: NavigationRoute) => { + if (!route.key) { + console.error(`The route passed to showWideRHPVersion should have the "key" property defined.`); + return; + } + + const newKey = route.key; + + // If the key is in the array, don't add it. + setSuperWideRHPRouteKeys((prev) => (prev.includes(newKey) ? prev : [newKey, ...prev])); + }, []); + /** * Removes a route from the wide RHP route keys list, disabling wide RHP display for that route. */ @@ -171,13 +210,14 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const keyToRemove = route.key; // Do nothing, the key is not here - if (!allWideRHPRouteKeys.includes(keyToRemove)) { + if (!allWideRHPRouteKeys.includes(keyToRemove) && !superWideRHPRouteKeys.includes(keyToRemove)) { return; } setAllWideRHPRouteKeys((prev) => (prev.includes(keyToRemove) ? prev.filter((key) => key !== keyToRemove) : prev)); + setSuperWideRHPRouteKeys((prev) => (prev.includes(keyToRemove) ? prev.filter((key) => key !== keyToRemove) : prev)); }, - [allWideRHPRouteKeys], + [allWideRHPRouteKeys, superWideRHPRouteKeys], ); /** @@ -229,12 +269,14 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { * Effect that shows/hides the expanded RHP progress based on the number of wide RHP routes. */ useEffect(() => { - if (wideRHPRouteKeys.length > 0) { - expandedRHPProgress.setValue(1); + if (superWideRHPRouteKeys.length > 0) { + expandedRHPProgress.set(2); + } else if (wideRHPRouteKeys.length > 0) { + expandedRHPProgress.set(1); } else { - expandedRHPProgress.setValue(0); + expandedRHPProgress.set(0); } - }, [wideRHPRouteKeys.length]); + }, [expandedRHPProgress, superWideRHPRouteKeys.length, wideRHPRouteKeys.length]); /** * Effect that manages the secondary overlay animation and rendering state. @@ -258,6 +300,28 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { } }, [shouldShowSecondaryOverlay]); + /** + * Effect that manages the secondary overlay animation and rendering state. + */ + useEffect(() => { + if (shouldShowThirdOverlay) { + setShouldRenderThirdOverlay(true); + Animated.timing(thirdOverlayProgress, { + toValue: 1, + duration: 300, + useNativeDriver: false, + }).start(); + } else { + Animated.timing(thirdOverlayProgress, { + toValue: 0, + duration: 300, + useNativeDriver: false, + }).start(() => { + setShouldRenderThirdOverlay(false); + }); + } + }, [shouldShowThirdOverlay]); + /** * Effect that handles responsive RHP width calculation when window dimensions change. * Listens for dimension changes and recalculates the optimal RHP width accordingly. @@ -284,15 +348,31 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { () => ({ expandedRHPProgress, wideRHPRouteKeys, + superWideRHPRouteKeys, showWideRHPVersion, + showSuperWideRHPVersion, cleanWideRHPRouteKey, secondOverlayProgress, + thirdOverlayProgress, shouldRenderSecondaryOverlay, + shouldRenderThirdOverlay, dismissToWideReport, markReportIDAsExpense, isReportIDMarkedAsExpense, }), - [wideRHPRouteKeys, showWideRHPVersion, cleanWideRHPRouteKey, shouldRenderSecondaryOverlay, dismissToWideReport, markReportIDAsExpense, isReportIDMarkedAsExpense], + [ + expandedRHPProgress, + wideRHPRouteKeys, + superWideRHPRouteKeys, + showWideRHPVersion, + showSuperWideRHPVersion, + cleanWideRHPRouteKey, + shouldRenderSecondaryOverlay, + shouldRenderThirdOverlay, + dismissToWideReport, + markReportIDAsExpense, + isReportIDMarkedAsExpense, + ], ); return {children}; @@ -339,8 +419,41 @@ function useShowWideRHPVersion(condition: boolean) { }, [condition, reportID, isReportIDMarkedAsExpense, route, showWideRHPVersion]); } +function useShowSuperWideRHPVersion(condition: boolean) { + const navigation = useNavigation(); + const route = useRoute(); + const reportID = route.params && 'reportID' in route.params && typeof route.params.reportID === 'string' ? route.params.reportID : ''; + const {showWideRHPVersion, showSuperWideRHPVersion, cleanWideRHPRouteKey, isReportIDMarkedAsExpense} = useContext(WideRHPContext); + + /** + * Effect that sets up cleanup when the screen is about to be removed. + * Uses InteractionManager to ensure cleanup happens after closing animation. + */ + useEffect(() => { + return navigation.addListener('beforeRemove', () => { + // eslint-disable-next-line @typescript-eslint/no-deprecated + InteractionManager.runAfterInteractions(() => { + cleanWideRHPRouteKey(route); + }); + }); + }, [cleanWideRHPRouteKey, navigation, route]); + + /** + * Effect that determines whether to show wide RHP based on condition or optimistic state. + * Shows wide RHP if either the condition is true OR the reportID is marked as an expense. + */ + useEffect(() => { + // Check if we should show wide RHP based on condition OR if reportID is in optimistic set + if (!condition) { + showWideRHPVersion(route); + return; + } + showSuperWideRHPVersion(route); + }, [condition, reportID, isReportIDMarkedAsExpense, route, showWideRHPVersion, showSuperWideRHPVersion]); +} + WideRHPContextProvider.displayName = 'WideRHPContextProvider'; export default WideRHPContextProvider; -export {expandedRHPProgress, receiptPaneRHPWidth, secondOverlayProgress, useShowWideRHPVersion, WideRHPContext, extractNavigationKeys}; +export {calculateReceiptPaneRHPWidth, extractNavigationKeys, receiptPaneRHPWidth, secondOverlayProgress, useShowSuperWideRHPVersion, useShowWideRHPVersion, WideRHPContext}; diff --git a/src/components/WideRHPContextProvider/types.ts b/src/components/WideRHPContextProvider/types.ts index 630195bda6ad..8d9189d7cb5a 100644 --- a/src/components/WideRHPContextProvider/types.ts +++ b/src/components/WideRHPContextProvider/types.ts @@ -1,23 +1,36 @@ // eslint-disable-next-line no-restricted-imports import type {Animated} from 'react-native'; +import type {SharedValue} from 'react-native-reanimated'; import type {NavigationRoute} from '@libs/Navigation/types'; type WideRHPContextType = { // Route keys of screens that should be displayed in wide format wideRHPRouteKeys: string[]; + // Route keys of screens that should be displayed in super wide format + superWideRHPRouteKeys: string[]; + // Progress of changing format: 0 - narrow, 1 - wide - expandedRHPProgress: Animated.Value; + expandedRHPProgress: SharedValue; // Progress of the secondary overlay, the one covering wider RHP screen secondOverlayProgress: Animated.Value; + // Progress of the secondary overlay, the one covering wider RHP screen + thirdOverlayProgress: Animated.Value; + // If the secondary overlay should be rendered. This value takes into account the delay of closing transition. shouldRenderSecondaryOverlay: boolean; + // If the secondary overlay should be rendered. This value takes into account the delay of closing transition. + shouldRenderThirdOverlay: boolean; + // Show given route as in wide format showWideRHPVersion: (route: NavigationRoute) => void; + // Show given route as in super wide format + showSuperWideRHPVersion: (route: NavigationRoute) => void; + // Remove given route from the array cleanWideRHPRouteKey: (route: NavigationRoute) => void; diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 68b999b00c54..93068bfe20d0 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -35,6 +35,7 @@ import type { RoomMembersNavigatorParamList, ScheduleCallParamList, SearchAdvancedFiltersParamList, + SearchMoneyRequestReportParamList, SearchReportParamList, SearchSavedSearchParamList, SetDefaultWorkspaceNavigatorParamList, @@ -833,6 +834,9 @@ const SearchReportModalStackNavigator = createModalStackNavigator require('../../../../pages/Search/SearchHoldReasonPage').default, [SCREENS.SEARCH.TRANSACTION_HOLD_REASON_RHP]: () => require('../../../../pages/Search/SearchHoldReasonPage').default, [SCREENS.SEARCH.TRANSACTIONS_CHANGE_REPORT_SEARCH_RHP]: () => require('../../../../pages/Search/SearchTransactionsChangeReport').default, +}); + +const SearchMoneyRequestReportNavigator = createModalStackNavigator({ [SCREENS.SEARCH.MONEY_REQUEST_REPORT]: () => require('../../../../pages/Search/SearchMoneyRequestReportPage').default, }); @@ -963,4 +967,5 @@ export { AddUnreportedExpenseModalStackNavigator, ScheduleCallModalStackNavigator, MergeTransactionStackNavigator, + SearchMoneyRequestReportNavigator, }; diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/useModalStackScreenOptions.ts b/src/libs/Navigation/AppNavigator/ModalStackNavigators/useModalStackScreenOptions.ts index 7703f6712edd..4a80e00f7f76 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/useModalStackScreenOptions.ts +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/useModalStackScreenOptions.ts @@ -4,6 +4,7 @@ import {useCallback, useContext} from 'react'; import {WideRHPContext} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; +import useWindowDimensions from '@hooks/useWindowDimensions'; import enhanceCardStyleInterpolator from '@libs/Navigation/AppNavigator/enhanceCardStyleInterpolator'; import hideKeyboardOnSwipe from '@libs/Navigation/AppNavigator/hideKeyboardOnSwipe'; import type {PlatformStackNavigationOptions, PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types'; @@ -16,17 +17,22 @@ function useModalStackScreenOptions() { // https://github.com/Expensify/App/issues/63747 // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth const {isSmallScreenWidth} = useResponsiveLayout(); - const {wideRHPRouteKeys} = useContext(WideRHPContext); + const {wideRHPRouteKeys, superWideRHPRouteKeys} = useContext(WideRHPContext); + const {windowWidth} = useWindowDimensions(); return useCallback<({route}: {route: PlatformStackRouteProp}) => PlatformStackNavigationOptions>( ({route}) => { let cardStyleInterpolator; - if (wideRHPRouteKeys.includes(route.key) && !isSmallScreenWidth) { + if (superWideRHPRouteKeys.includes(route.key) && !isSmallScreenWidth) { + cardStyleInterpolator = enhanceCardStyleInterpolator(CardStyleInterpolators.forHorizontalIOS, { + cardStyle: styles.superWideRHPExtendedCardInterpolatorStyles(windowWidth), + }); + } else if (wideRHPRouteKeys.includes(route.key) && !isSmallScreenWidth) { // We need to use interpolator styles instead of regular card styles so we can use animated value for width. // It is necessary to have responsive width of the wide RHP for range 800px to 840px. cardStyleInterpolator = enhanceCardStyleInterpolator(CardStyleInterpolators.forHorizontalIOS, { - cardStyle: styles.wideRHPExtendedCardInterpolatorStyles, + cardStyle: styles.wideRHPExtendedCardInterpolatorStyles(windowWidth), }); } else { cardStyleInterpolator = CardStyleInterpolators.forHorizontalIOS; @@ -45,7 +51,7 @@ function useModalStackScreenOptions() { }, }; }, - [isSmallScreenWidth, styles.navigationScreenCardStyle, styles.wideRHPExtendedCardInterpolatorStyles, wideRHPRouteKeys], + [isSmallScreenWidth, styles, superWideRHPRouteKeys, wideRHPRouteKeys, windowWidth], ); } diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index 6c6e525903b3..d4dfcaa04c77 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -1,13 +1,14 @@ import type {NavigatorScreenParams} from '@react-navigation/native'; import React, {useCallback, useContext, useMemo, useRef} from 'react'; +import {InteractionManager} from 'react-native'; +import Animated, {interpolate, useAnimatedStyle} from 'react-native-reanimated'; // We use Animated for all functionality related to wide RHP to make it easier // to interact with react-navigation components (e.g., CardContainer, interpolator), which also use Animated. // eslint-disable-next-line no-restricted-imports -import {Animated, InteractionManager} from 'react-native'; import NoDropZone from '@components/DragAndDrop/NoDropZone'; -import {expandedRHPProgress, WideRHPContext} from '@components/WideRHPContextProvider'; +import {calculateReceiptPaneRHPWidth, WideRHPContext} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; -import useThemeStyles from '@hooks/useThemeStyles'; +import useWindowDimensions from '@hooks/useWindowDimensions'; import {abandonReviewDuplicateTransactions} from '@libs/actions/Transaction'; import {clearTwoFactorAuthData} from '@libs/actions/TwoFactorAuthActions'; import hideKeyboardOnSwipe from '@libs/Navigation/AppNavigator/hideKeyboardOnSwipe'; @@ -16,6 +17,7 @@ import useRHPScreenOptions from '@libs/Navigation/AppNavigator/useRHPScreenOptio import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {AuthScreensParamList, RightModalNavigatorParamList} from '@navigation/types'; +import variables from '@styles/variables'; import CONST from '@src/CONST'; import NAVIGATORS from '@src/NAVIGATORS'; import SCREENS from '@src/SCREENS'; @@ -27,11 +29,27 @@ type RightModalNavigatorProps = PlatformStackScreenProps(); function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { - const styles = useThemeStyles(); const {shouldUseNarrowLayout} = useResponsiveLayout(); const isExecutingRef = useRef(false); const screenOptions = useRHPScreenOptions(); - const {shouldRenderSecondaryOverlay, secondOverlayProgress, dismissToWideReport} = useContext(WideRHPContext); + const {expandedRHPProgress, shouldRenderSecondaryOverlay, secondOverlayProgress, shouldRenderThirdOverlay, thirdOverlayProgress, dismissToWideReport} = useContext(WideRHPContext); + const {windowWidth} = useWindowDimensions(); + + const animatedStyle = useAnimatedStyle(() => { + const width = interpolate( + expandedRHPProgress.get(), + [0, 1, 2], + [variables.sideBarWidth, variables.sideBarWidth + calculateReceiptPaneRHPWidth(windowWidth), windowWidth - variables.navigationTabBarSize - variables.sideBarWithLHBWidth], + ); + + return { + height: '100%', + right: 0, + position: 'absolute', + overflow: 'hidden', + width: shouldUseNarrowLayout ? '100%' : width, + }; + }); const screenListeners = useMemo( () => ({ @@ -71,7 +89,7 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { {!shouldUseNarrowLayout && } {/* This one is to limit the outer Animated.View and allow the background to be pressable */} {/* Without it, the transparent half of the narrow format RHP card would cover the pressable part of the overlay */} - + + { // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth const {isSmallScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout(); const themeStyles = useThemeStyles(); + const {expandedRHPProgress} = useContext(WideRHPContext); return { rightModalNavigator: { @@ -54,7 +56,7 @@ const useRootNavigatorScreenOptions = () => { // Adjust output range to match the wide RHP size outputRangeMultiplier: isSmallScreenWidth ? undefined - : Animated.add(Animated.multiply(expandedRHPProgress, variables.receiptPaneRHPMaxWidth / variables.sideBarWidth), 1), + : Animated.add(Animated.multiply(expandedRHPProgress.get(), variables.receiptPaneRHPMaxWidth / variables.sideBarWidth), 1), }), }, }, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 0d66b0118101..515dd60fa6e2 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -1542,12 +1542,16 @@ const config: LinkingOptions['config'] = { [SCREENS.RIGHT_MODAL.SEARCH_REPORT]: { screens: { [SCREENS.SEARCH.REPORT_RHP]: ROUTES.SEARCH_REPORT.route, - [SCREENS.SEARCH.MONEY_REQUEST_REPORT]: ROUTES.SEARCH_MONEY_REQUEST_REPORT.route, [SCREENS.SEARCH.MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS]: ROUTES.SEARCH_MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS.route, [SCREENS.SEARCH.TRANSACTION_HOLD_REASON_RHP]: ROUTES.TRANSACTION_HOLD_REASON_RHP, [SCREENS.SEARCH.TRANSACTIONS_CHANGE_REPORT_SEARCH_RHP]: ROUTES.MOVE_TRANSACTIONS_SEARCH_RHP, }, }, + [SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT]: { + screens: { + [SCREENS.SEARCH.MONEY_REQUEST_REPORT]: ROUTES.SEARCH_MONEY_REQUEST_REPORT.route, + }, + }, [SCREENS.RIGHT_MODAL.SEARCH_ADVANCED_FILTERS]: { screens: { [SCREENS.SEARCH.ADVANCED_FILTERS_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS.getRoute(), diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 7beb4293c098..5be9ddae4a53 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -2070,6 +2070,7 @@ type RightModalNavigatorParamList = { [SCREENS.RIGHT_MODAL.TRANSACTION_DUPLICATE]: NavigatorScreenParams; [SCREENS.RIGHT_MODAL.TRAVEL]: NavigatorScreenParams; [SCREENS.RIGHT_MODAL.SEARCH_REPORT]: NavigatorScreenParams; + [SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT]: NavigatorScreenParams; [SCREENS.RIGHT_MODAL.RESTRICTED_ACTION]: NavigatorScreenParams; [SCREENS.RIGHT_MODAL.SEARCH_ADVANCED_FILTERS]: NavigatorScreenParams; [SCREENS.RIGHT_MODAL.SEARCH_SAVED_SEARCH]: NavigatorScreenParams; @@ -2558,6 +2559,9 @@ type SearchReportParamList = { /** Selected transactions' report ID */ reportID: string; }; +}; + +type SearchMoneyRequestReportParamList = { [SCREENS.SEARCH.MONEY_REQUEST_REPORT]: { reportID: string; // eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md @@ -2780,4 +2784,5 @@ export type { TestToolsModalModalNavigatorParamList, MergeTransactionNavigatorParamList, AttachmentModalScreensParamList, + SearchMoneyRequestReportParamList, }; diff --git a/src/pages/Search/SearchMoneyRequestReportPage.tsx b/src/pages/Search/SearchMoneyRequestReportPage.tsx index b8024ce803e7..7403b0b7c706 100644 --- a/src/pages/Search/SearchMoneyRequestReportPage.tsx +++ b/src/pages/Search/SearchMoneyRequestReportPage.tsx @@ -7,6 +7,7 @@ import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView import DragAndDropProvider from '@components/DragAndDrop/Provider'; import MoneyRequestReportView from '@components/MoneyRequestReportView/MoneyRequestReportView'; import ScreenWrapper from '@components/ScreenWrapper'; +import {useShowSuperWideRHPVersion} from '@components/WideRHPContextProvider'; import useIsReportReadyToDisplay from '@hooks/useIsReportReadyToDisplay'; import useNetwork from '@hooks/useNetwork'; import useOnyx from '@hooks/useOnyx'; @@ -78,6 +79,11 @@ function SearchMoneyRequestReportPage({route}: SearchMoneyRequestPageProps) { const reportID = report?.reportID; + // If there is more than one transaction, display the report in Super Wide RHP, otherwise it will be shown in Wide RHP + const shouldShowSuperWideRHP = visibleTransactions.length > 1; + + useShowSuperWideRHPVersion(shouldShowSuperWideRHP); + useEffect(() => { if (transactionThreadReportID === CONST.FAKE_REPORT_ID && oneTransactionID) { const iouAction = getIOUActionForTransactionID(reportActions, oneTransactionID); diff --git a/src/styles/index.ts b/src/styles/index.ts index 3aeef1bab836..0e8d87c0b0e8 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -7,13 +7,13 @@ import type {ImageStyle, TextStyle, ViewStyle} from 'react-native'; // eslint-disable-next-line no-restricted-imports import {Animated, Platform, StyleSheet} from 'react-native'; import type {PickerStyle} from 'react-native-picker-select'; -import {interpolate} from 'react-native-reanimated'; import type {SharedValue} from 'react-native-reanimated'; +import {interpolate} from 'react-native-reanimated'; import type {MixedStyleDeclaration, MixedStyleRecord} from 'react-native-render-html'; import type {ValueOf} from 'type-fest'; import type DotLottieAnimation from '@components/LottieAnimations/types'; import {ACTIVE_LABEL_SCALE} from '@components/TextInput/styleConst'; -import {receiptPaneRHPWidth} from '@components/WideRHPContextProvider'; +import {calculateReceiptPaneRHPWidth, receiptPaneRHPWidth} from '@components/WideRHPContextProvider'; import {getBrowser, isMobile, isMobileSafari, isSafari} from '@libs/Browser'; import getPlatform from '@libs/getPlatform'; import CONST from '@src/CONST'; @@ -5324,12 +5324,19 @@ const staticStyles = (theme: ThemeColors) => backgroundColor: colors.green800, }, - wideRHPExtendedCardInterpolatorStyles: { + wideRHPExtendedCardInterpolatorStyles: (windowWidth: number) => ({ position: Platform.OS === 'web' ? 'fixed' : 'absolute', height: '100%', right: 0, - width: Animated.add(variables.sideBarWidth, receiptPaneRHPWidth), - }, + width: Animated.add(variables.sideBarWidth, calculateReceiptPaneRHPWidth(windowWidth)), + }), + + superWideRHPExtendedCardInterpolatorStyles: (windowWidth: number) => ({ + position: Platform.OS === 'web' ? 'fixed' : 'absolute', + height: '100%', + right: 0, + width: Animated.subtract(windowWidth, variables.navigationTabBarSize + variables.sideBarWithLHBWidth), + }), flexibleHeight: { height: 'auto', From 017f1347a8cc80614301fa062f1a38896c1d685a Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Tue, 28 Oct 2025 20:13:19 +0100 Subject: [PATCH 03/64] Refactor BaseOverlay margin props --- .../ModalStackNavigators/index.tsx | 50 +++++++++---------- .../Navigators/Overlay/BaseOverlay.tsx | 23 +++------ .../Navigators/RightModalNavigator.tsx | 15 ++++-- src/styles/index.ts | 14 +++--- 4 files changed, 48 insertions(+), 54 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 93068bfe20d0..0a596a91bea2 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -2,7 +2,7 @@ import {useRoute} from '@react-navigation/native'; import type {ParamListBase} from '@react-navigation/routers'; import React, {useCallback, useContext} from 'react'; import {View} from 'react-native'; -import {WideRHPContext} from '@components/WideRHPContextProvider'; +import {receiptPaneRHPWidth, WideRHPContext} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import Overlay from '@libs/Navigation/AppNavigator/Navigators/Overlay'; @@ -129,7 +129,7 @@ function createModalStackNavigator(screens: Scr // This overlay is necessary to cover the gap under the narrow format RHP screen ) : null} @@ -923,49 +923,49 @@ const ScheduleCallModalStackNavigator = createModalStackNavigator void; - /* Whether there should be a gap on the right side. Necessary for the overlay that covers wider part of RHP. */ - hasMarginRight?: boolean; - - /* Whether there should be a gap on the left. Necessary for the overlay in modal stack navigator. */ - hasMarginLeft?: boolean; - /* Override the progress from useCardAnimation. Necessary for the secondary overlay */ progress?: OverlayStylesParams; + + positionLeftValue?: number | Animated.Value; + + positionRightValue?: number | Animated.Value; }; -function BaseOverlay({onPress, hasMarginRight = false, progress, hasMarginLeft = false}: BaseOverlayProps) { +function BaseOverlay({onPress, progress, positionLeftValue = -2 * variables.sideBarWidth, positionRightValue = 0}: BaseOverlayProps) { const styles = useThemeStyles(); const {current} = useCardAnimation(); const {translate} = useLocalize(); - const {sidePanelTranslateX} = useSidePanel(); return ( {/* In the latest Electron version buttons can't be both clickable and draggable. diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index d4dfcaa04c77..0d820f45aaa3 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -1,19 +1,21 @@ import type {NavigatorScreenParams} from '@react-navigation/native'; import React, {useCallback, useContext, useMemo, useRef} from 'react'; -import {InteractionManager} from 'react-native'; -import Animated, {interpolate, useAnimatedStyle} from 'react-native-reanimated'; // We use Animated for all functionality related to wide RHP to make it easier // to interact with react-navigation components (e.g., CardContainer, interpolator), which also use Animated. // eslint-disable-next-line no-restricted-imports +import {InteractionManager, Animated as RNAnimated} from 'react-native'; +import Animated, {interpolate, useAnimatedStyle} from 'react-native-reanimated'; import NoDropZone from '@components/DragAndDrop/NoDropZone'; import {calculateReceiptPaneRHPWidth, WideRHPContext} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; +import useSidePanel from '@hooks/useSidePanel'; import useWindowDimensions from '@hooks/useWindowDimensions'; import {abandonReviewDuplicateTransactions} from '@libs/actions/Transaction'; import {clearTwoFactorAuthData} from '@libs/actions/TwoFactorAuthActions'; import hideKeyboardOnSwipe from '@libs/Navigation/AppNavigator/hideKeyboardOnSwipe'; import * as ModalStackNavigators from '@libs/Navigation/AppNavigator/ModalStackNavigators'; import useRHPScreenOptions from '@libs/Navigation/AppNavigator/useRHPScreenOptions'; +import Navigation from '@libs/Navigation/Navigation'; import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {AuthScreensParamList, RightModalNavigatorParamList} from '@navigation/types'; @@ -32,8 +34,11 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { const {shouldUseNarrowLayout} = useResponsiveLayout(); const isExecutingRef = useRef(false); const screenOptions = useRHPScreenOptions(); - const {expandedRHPProgress, shouldRenderSecondaryOverlay, secondOverlayProgress, shouldRenderThirdOverlay, thirdOverlayProgress, dismissToWideReport} = useContext(WideRHPContext); + const {expandedRHPProgress, shouldRenderSecondaryOverlay, secondOverlayProgress} = useContext(WideRHPContext); const {windowWidth} = useWindowDimensions(); + const {sidePanelTranslateX} = useSidePanel(); + + const secondaryOverlayPositionRight = RNAnimated.add(variables.sideBarWidth, sidePanelTranslateX ? RNAnimated.subtract(variables.sideBarWidth, sidePanelTranslateX.current) : 0); const animatedStyle = useAnimatedStyle(() => { const width = interpolate( @@ -284,9 +289,9 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { {/* It has a gap on the right to make the last rhp route (narrow) visible and pressable */} {shouldRenderSecondaryOverlay && !shouldUseNarrowLayout && ( Navigation.closeRHPFlow()} /> )} diff --git a/src/styles/index.ts b/src/styles/index.ts index 0e8d87c0b0e8..175580e43b97 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -5580,19 +5580,17 @@ const dynamicStyles = (theme: ThemeColors) => overlayStyles: ({ progress, - hasMarginRight = false, - hasMarginLeft = false, - sidePanelTranslateX, + positionLeftValue, + positionRightValue, }: { progress: OverlayStylesParams; - hasMarginRight?: boolean; - hasMarginLeft?: boolean; - sidePanelTranslateX?: RefObject; + positionLeftValue: number | Animated.Value; + positionRightValue: number | Animated.Value; }) => ({ // We need to stretch the overlay to cover the sidebar and the translate animation distance. - left: hasMarginLeft ? receiptPaneRHPWidth : -2 * variables.sideBarWidth, - right: hasMarginRight ? Animated.add(variables.sideBarWidth, sidePanelTranslateX ? Animated.subtract(variables.sideBarWidth, sidePanelTranslateX.current) : 0) : 0, + left: positionLeftValue, + right: positionRightValue, opacity: progress.interpolate({ inputRange: [0, 1], outputRange: [0, variables.overlayOpacity], From 0f1fb88c63b0041db6511e42b26032f1a3c6bd10 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Wed, 29 Oct 2025 08:46:27 +0100 Subject: [PATCH 04/64] Adjust overlays --- .../WideRHPContextProvider/index.tsx | 26 +++++++++++++++---- .../ModalStackNavigators/index.tsx | 23 +++++++++++++--- .../Navigators/RightModalNavigator.tsx | 10 ++++++- 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index c73440625197..b5072a31aeec 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -86,6 +86,8 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const expandedRHPProgress = useSharedValue(0); + const focusedRouteKey = useRootNavigationState((state) => findFocusedRoute(state))?.key; + // Return undefined if RHP is not the last route const lastVisibleRHPRouteKey = useRootNavigationState((state) => { // Safe handling when navigation is not yet initialized @@ -122,6 +124,10 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { return currentKeys; }, [allWideRHPRouteKeys, lastVisibleRHPRouteKey]); + const isWideRhpFocused = useMemo(() => { + return focusedRouteKey && wideRHPRouteKeys.includes(focusedRouteKey); + }, [focusedRouteKey, wideRHPRouteKeys]); + /** * Determines whether the secondary overlay should be displayed. * Shows second overlay when RHP is open and there is a wide RHP route open but there is another regular route on the top. @@ -140,6 +146,14 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { return false; } + if (superWideRHPRouteKeys.includes(focusedRoute.key) && wideRHPRouteKeys.length > 0) { + return false; + } + + if (superWideRHPRouteKeys.length > 0 && !superWideRHPRouteKeys.includes(focusedRoute.key) && isRHPLastRootRoute && focusedRoute.name !== SCREENS.SEARCH.MONEY_REQUEST_REPORT) { + return true; + } + // Check the focused route to avoid glitching when quickly close and open RHP. if (wideRHPRouteKeys.length > 0 && !wideRHPRouteKeys.includes(focusedRoute.key) && isRHPLastRootRoute && focusedRoute.name !== SCREENS.SEARCH.REPORT_RHP) { return true; @@ -162,12 +176,12 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { return false; } - // Check the focused route to avoid glitching when quickly close and open RHP. - if (superWideRHPRouteKeys.length > 0 && !superWideRHPRouteKeys.includes(focusedRoute.key) && isRHPLastRootRoute && focusedRoute.name !== SCREENS.SEARCH.MONEY_REQUEST_REPORT) { - return true; - } + const isSuperWideRhpDisplayedBelow = + superWideRHPRouteKeys.length > 0 && !superWideRHPRouteKeys.includes(focusedRoute.key) && focusedRoute.name !== SCREENS.SEARCH.MONEY_REQUEST_REPORT; + const isWideRhpDisplayedBelow = wideRHPRouteKeys.length > 0 && !wideRHPRouteKeys.includes(focusedRoute.key) && focusedRoute.name !== SCREENS.SEARCH.REPORT_RHP; - return false; + // Check the focused route to avoid glitching when quickly close and open RHP. + return isSuperWideRhpDisplayedBelow && isWideRhpDisplayedBelow && isRHPLastRootRoute; }); /** @@ -359,6 +373,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { dismissToWideReport, markReportIDAsExpense, isReportIDMarkedAsExpense, + isWideRhpFocused, }), [ expandedRHPProgress, @@ -372,6 +387,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { dismissToWideReport, markReportIDAsExpense, isReportIDMarkedAsExpense, + isWideRhpFocused, ], ); diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 0a596a91bea2..386d8b226233 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -1,10 +1,11 @@ -import {useRoute} from '@react-navigation/native'; +import {useIsFocused, useRoute} from '@react-navigation/native'; import type {ParamListBase} from '@react-navigation/routers'; import React, {useCallback, useContext} from 'react'; import {View} from 'react-native'; import {receiptPaneRHPWidth, WideRHPContext} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; +import useWindowDimensions from '@hooks/useWindowDimensions'; import Overlay from '@libs/Navigation/AppNavigator/Navigators/Overlay'; import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; import Animations from '@libs/Navigation/PlatformStackNavigation/navigationOptions/animation'; @@ -51,6 +52,7 @@ import type { WorkspaceConfirmationNavigatorParamList, WorkspaceDuplicateNavigatorParamList, } from '@navigation/types'; +import variables from '@styles/variables'; import type {Screen} from '@src/SCREENS'; import SCREENS from '@src/SCREENS'; import type ReactComponentModule from '@src/types/utils/ReactComponentModule'; @@ -93,8 +95,11 @@ function createModalStackNavigator(screens: Scr function ModalStack() { const styles = useThemeStyles(); const screenOptions = useModalStackScreenOptions(); - const {secondOverlayProgress, shouldRenderSecondaryOverlay} = useContext(WideRHPContext); + const {secondOverlayProgress, shouldRenderSecondaryOverlay, thirdOverlayProgress, shouldRenderThirdOverlay} = useContext(WideRHPContext); const route = useRoute(); + const {windowWidth} = useWindowDimensions(); + + const isFocused = useIsFocused(); // We have to use the isSmallScreenWidth instead of shouldUseNarrow layout, because we want to have information about screen width without the context of side modal. // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth @@ -125,13 +130,25 @@ function createModalStackNavigator(screens: Scr /> ))} - {!isSmallScreenWidth && shouldRenderSecondaryOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT ? ( + {!isSmallScreenWidth && shouldRenderSecondaryOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT && !isFocused ? ( // This overlay is necessary to cover the gap under the narrow format RHP screen ) : null} + {!isSmallScreenWidth && shouldRenderSecondaryOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT && !isFocused ? ( + + ) : null} + {!isSmallScreenWidth && shouldRenderThirdOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT ? ( + + ) : null} ); } diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index 0d820f45aaa3..f6412de692e2 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -34,7 +34,8 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { const {shouldUseNarrowLayout} = useResponsiveLayout(); const isExecutingRef = useRef(false); const screenOptions = useRHPScreenOptions(); - const {expandedRHPProgress, shouldRenderSecondaryOverlay, secondOverlayProgress} = useContext(WideRHPContext); + const {expandedRHPProgress, shouldRenderSecondaryOverlay, secondOverlayProgress, isWideRhpFocused, wideRHPRouteKeys, shouldRenderThirdOverlay, thirdOverlayProgress} = + useContext(WideRHPContext); const {windowWidth} = useWindowDimensions(); const {sidePanelTranslateX} = useSidePanel(); @@ -290,6 +291,13 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { {shouldRenderSecondaryOverlay && !shouldUseNarrowLayout && ( Navigation.closeRHPFlow()} + /> + )} + {shouldRenderThirdOverlay && !shouldUseNarrowLayout && ( + Navigation.closeRHPFlow()} /> From 1bbf882faf2d7e543cfb925a5d8b004018e89234 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Tue, 4 Nov 2025 20:05:43 +0100 Subject: [PATCH 05/64] Adjust overlays widths --- .../WideRHPContextProvider/index.tsx | 32 +++++++++++++++---- .../ModalStackNavigators/index.tsx | 20 +++++++----- .../Navigators/RightModalNavigator.tsx | 32 ++++++++++--------- 3 files changed, 55 insertions(+), 29 deletions(-) diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index b5072a31aeec..469c68aaba02 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -20,7 +20,9 @@ import type {WideRHPContextType} from './types'; const secondOverlayProgress = new Animated.Value(0); const thirdOverlayProgress = new Animated.Value(0); -const wideRHPMaxWidth = variables.receiptPaneRHPMaxWidth + variables.sideBarWidth; +const singleRHPWidth = variables.sideBarWidth; +const wideRHPMaxWidth = variables.receiptPaneRHPMaxWidth + singleRHPWidth; +const sidebarWidth = variables.sideBarWithLHBWidth + variables.navigationTabBarSize; /** * Utility function that extracts all unique navigation keys from a React Navigation state. @@ -67,12 +69,16 @@ function extractNavigationKeys(state: NavigationState | PartialState { const calculatedWidth = windowWidth < wideRHPMaxWidth ? variables.receiptPaneRHPMaxWidth - (wideRHPMaxWidth - windowWidth) : variables.receiptPaneRHPMaxWidth; - return Math.max(calculatedWidth, variables.mobileResponsiveWidthBreakpoint - variables.sideBarWidth); + return Math.max(calculatedWidth, variables.mobileResponsiveWidthBreakpoint - singleRHPWidth); }; // This animated value is necessary to have a responsive RHP width for the range 800px to 840px. const receiptPaneRHPWidth = new Animated.Value(calculateReceiptPaneRHPWidth(Dimensions.get('window').width)); +const wideRHPWidth = new Animated.Value(calculateReceiptPaneRHPWidth(Dimensions.get('window').width) + singleRHPWidth); +const modalStackOverlayWideRHPWidth = new Animated.Value(Dimensions.get('window').width - sidebarWidth - calculateReceiptPaneRHPWidth(Dimensions.get('window').width - singleRHPWidth)); +const modalStackOverlaySuperWideRHPWidth = new Animated.Value(Dimensions.get('window').width - sidebarWidth - singleRHPWidth); + const WideRHPContext = createContext(defaultWideRHPContextValue); function WideRHPContextProvider({children}: React.PropsWithChildren) { @@ -343,9 +349,12 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { useEffect(() => { const handleDimensionChange = () => { const windowWidth = Dimensions.get('window').width; - const newWidth = calculateReceiptPaneRHPWidth(windowWidth); - - receiptPaneRHPWidth.setValue(newWidth); + const newReceiptPaneRHPWidth = calculateReceiptPaneRHPWidth(windowWidth); + const newWideRHPWidth = newReceiptPaneRHPWidth + singleRHPWidth; + receiptPaneRHPWidth.setValue(newReceiptPaneRHPWidth); + wideRHPWidth.setValue(newWideRHPWidth); + modalStackOverlayWideRHPWidth.setValue(windowWidth - newWideRHPWidth - sidebarWidth); + modalStackOverlaySuperWideRHPWidth.setValue(windowWidth - sidebarWidth - singleRHPWidth); }; // Set initial value @@ -472,4 +481,15 @@ WideRHPContextProvider.displayName = 'WideRHPContextProvider'; export default WideRHPContextProvider; -export {calculateReceiptPaneRHPWidth, extractNavigationKeys, receiptPaneRHPWidth, secondOverlayProgress, useShowSuperWideRHPVersion, useShowWideRHPVersion, WideRHPContext}; +export { + calculateReceiptPaneRHPWidth, + extractNavigationKeys, + receiptPaneRHPWidth, + wideRHPWidth, + modalStackOverlayWideRHPWidth, + modalStackOverlaySuperWideRHPWidth, + secondOverlayProgress, + useShowSuperWideRHPVersion, + useShowWideRHPVersion, + WideRHPContext, +}; diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 386d8b226233..24f19a7f582e 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -2,10 +2,9 @@ import {useIsFocused, useRoute} from '@react-navigation/native'; import type {ParamListBase} from '@react-navigation/routers'; import React, {useCallback, useContext} from 'react'; import {View} from 'react-native'; -import {receiptPaneRHPWidth, WideRHPContext} from '@components/WideRHPContextProvider'; +import {modalStackOverlaySuperWideRHPWidth, modalStackOverlayWideRHPWidth, receiptPaneRHPWidth, WideRHPContext, wideRHPWidth} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; -import useWindowDimensions from '@hooks/useWindowDimensions'; import Overlay from '@libs/Navigation/AppNavigator/Navigators/Overlay'; import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; import Animations from '@libs/Navigation/PlatformStackNavigation/navigationOptions/animation'; @@ -95,9 +94,8 @@ function createModalStackNavigator(screens: Scr function ModalStack() { const styles = useThemeStyles(); const screenOptions = useModalStackScreenOptions(); - const {secondOverlayProgress, shouldRenderSecondaryOverlay, thirdOverlayProgress, shouldRenderThirdOverlay} = useContext(WideRHPContext); + const {secondOverlayProgress, shouldRenderSecondaryOverlay, thirdOverlayProgress, shouldRenderThirdOverlay, isWideRhpFocused} = useContext(WideRHPContext); const route = useRoute(); - const {windowWidth} = useWindowDimensions(); const isFocused = useIsFocused(); @@ -130,23 +128,29 @@ function createModalStackNavigator(screens: Scr /> ))} - {!isSmallScreenWidth && shouldRenderSecondaryOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT && !isFocused ? ( + {!isSmallScreenWidth && shouldRenderSecondaryOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT && !isFocused && !shouldRenderThirdOverlay ? ( // This overlay is necessary to cover the gap under the narrow format RHP screen ) : null} - {!isSmallScreenWidth && shouldRenderSecondaryOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT && !isFocused ? ( + {!isSmallScreenWidth && shouldRenderSecondaryOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT && !!isWideRhpFocused && !isFocused ? ( + ) : null} + {!isSmallScreenWidth && shouldRenderSecondaryOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT && !isWideRhpFocused && !isFocused ? ( + ) : null} {!isSmallScreenWidth && shouldRenderThirdOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT ? ( ) : null} diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index f6412de692e2..103325266ce9 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -1,14 +1,13 @@ import type {NavigatorScreenParams} from '@react-navigation/native'; import React, {useCallback, useContext, useMemo, useRef} from 'react'; +import {InteractionManager} from 'react-native'; // We use Animated for all functionality related to wide RHP to make it easier // to interact with react-navigation components (e.g., CardContainer, interpolator), which also use Animated. // eslint-disable-next-line no-restricted-imports -import {InteractionManager, Animated as RNAnimated} from 'react-native'; import Animated, {interpolate, useAnimatedStyle} from 'react-native-reanimated'; import NoDropZone from '@components/DragAndDrop/NoDropZone'; -import {calculateReceiptPaneRHPWidth, WideRHPContext} from '@components/WideRHPContextProvider'; +import {calculateReceiptPaneRHPWidth, WideRHPContext, wideRHPWidth} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; -import useSidePanel from '@hooks/useSidePanel'; import useWindowDimensions from '@hooks/useWindowDimensions'; import {abandonReviewDuplicateTransactions} from '@libs/actions/Transaction'; import {clearTwoFactorAuthData} from '@libs/actions/TwoFactorAuthActions'; @@ -30,23 +29,19 @@ type RightModalNavigatorProps = PlatformStackScreenProps(); +const singleRHPWidth = variables.sideBarWidth; +const getWideRHPWidth = (windowWidth: number) => variables.sideBarWidth + calculateReceiptPaneRHPWidth(windowWidth); +const getSuperWideRHPWidth = (windowWidth: number) => windowWidth - variables.sideBarWithLHBWidth - variables.navigationTabBarSize; + function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { const {shouldUseNarrowLayout} = useResponsiveLayout(); const isExecutingRef = useRef(false); const screenOptions = useRHPScreenOptions(); - const {expandedRHPProgress, shouldRenderSecondaryOverlay, secondOverlayProgress, isWideRhpFocused, wideRHPRouteKeys, shouldRenderThirdOverlay, thirdOverlayProgress} = - useContext(WideRHPContext); + const {expandedRHPProgress, shouldRenderSecondaryOverlay, secondOverlayProgress, isWideRhpFocused, shouldRenderThirdOverlay, thirdOverlayProgress} = useContext(WideRHPContext); const {windowWidth} = useWindowDimensions(); - const {sidePanelTranslateX} = useSidePanel(); - - const secondaryOverlayPositionRight = RNAnimated.add(variables.sideBarWidth, sidePanelTranslateX ? RNAnimated.subtract(variables.sideBarWidth, sidePanelTranslateX.current) : 0); const animatedStyle = useAnimatedStyle(() => { - const width = interpolate( - expandedRHPProgress.get(), - [0, 1, 2], - [variables.sideBarWidth, variables.sideBarWidth + calculateReceiptPaneRHPWidth(windowWidth), windowWidth - variables.navigationTabBarSize - variables.sideBarWithLHBWidth], - ); + const width = interpolate(expandedRHPProgress.get(), [0, 1, 2], [singleRHPWidth, getWideRHPWidth(windowWidth), getSuperWideRHPWidth(windowWidth)]); return { height: '100%', @@ -288,10 +283,17 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { {/* The second overlay is here to cover the wide rhp screen underneath */} {/* It has a gap on the right to make the last rhp route (narrow) visible and pressable */} - {shouldRenderSecondaryOverlay && !shouldUseNarrowLayout && ( + {shouldRenderSecondaryOverlay && !shouldUseNarrowLayout && !isWideRhpFocused && ( + Navigation.closeRHPFlow()} + /> + )} + {shouldRenderSecondaryOverlay && !shouldUseNarrowLayout && !!isWideRhpFocused && ( Navigation.closeRHPFlow()} /> )} From 80d917ab47af3578aed116685cc4b9832c17abd9 Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Wed, 5 Nov 2025 11:19:09 +0100 Subject: [PATCH 06/64] added handling for dynamic window size --- .../WideRHPContextProvider/index.tsx | 29 ++++++++++++++++++- .../Navigators/RightModalNavigator.tsx | 4 +-- src/styles/index.ts | 4 +-- src/styles/variables.ts | 1 + 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 2cfad4461d6a..db6c156db17f 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -75,8 +75,23 @@ const calculateReceiptPaneRHPWidth = (windowWidth: number) => { return Math.max(calculatedWidth, variables.mobileResponsiveWidthBreakpoint - variables.sideBarWidth); }; +/** + * Calculates the optimal width for the super wide RHP based on window width. + * Ensures the RHP doesn't exceed maximum width and maintains minimum responsive width. + * + * @param windowWidth - Current window width in pixels + * @returns Calculated super wide RHP width with constraints applied + */ +const calculateSuperWideRHPWidth = (windowWidth: number) => { + const SuperWideRHPWidth = windowWidth - variables.navigationTabBarSize - variables.sideBarWithLHBWidth; + const wideRHPWidth = calculateReceiptPaneRHPWidth(windowWidth) + variables.sideBarWidth; + + return Math.max(Math.min(SuperWideRHPWidth, variables.superWideRHPMaxWidth), wideRHPWidth); +}; + // This animated value is necessary to have a responsive RHP width for the range 800px to 840px. const receiptPaneRHPWidth = new Animated.Value(calculateReceiptPaneRHPWidth(Dimensions.get('window').width)); +const superWideRHPWidth = new Animated.Value(calculateSuperWideRHPWidth(Dimensions.get('window').width)); const WideRHPContext = createContext(defaultWideRHPContextValue); @@ -371,8 +386,10 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const handleDimensionChange = () => { const windowWidth = Dimensions.get('window').width; const newWidth = calculateReceiptPaneRHPWidth(windowWidth); + const newSuperWideRHPWidth = calculateSuperWideRHPWidth(windowWidth); receiptPaneRHPWidth.setValue(newWidth); + superWideRHPWidth.setValue(newSuperWideRHPWidth); }; // Set initial value @@ -499,4 +516,14 @@ WideRHPContextProvider.displayName = 'WideRHPContextProvider'; export default WideRHPContextProvider; -export {calculateReceiptPaneRHPWidth, extractNavigationKeys, receiptPaneRHPWidth, secondOverlayProgress, useShowSuperWideRHPVersion, useShowWideRHPVersion, WideRHPContext}; +export { + calculateReceiptPaneRHPWidth, + calculateSuperWideRHPWidth, + extractNavigationKeys, + receiptPaneRHPWidth, + superWideRHPWidth, + secondOverlayProgress, + useShowSuperWideRHPVersion, + useShowWideRHPVersion, + WideRHPContext, +}; diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index f6412de692e2..7644b13db097 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -6,7 +6,7 @@ import React, {useCallback, useContext, useMemo, useRef} from 'react'; import {InteractionManager, Animated as RNAnimated} from 'react-native'; import Animated, {interpolate, useAnimatedStyle} from 'react-native-reanimated'; import NoDropZone from '@components/DragAndDrop/NoDropZone'; -import {calculateReceiptPaneRHPWidth, WideRHPContext} from '@components/WideRHPContextProvider'; +import {calculateReceiptPaneRHPWidth, calculateSuperWideRHPWidth, WideRHPContext} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useSidePanel from '@hooks/useSidePanel'; import useWindowDimensions from '@hooks/useWindowDimensions'; @@ -45,7 +45,7 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { const width = interpolate( expandedRHPProgress.get(), [0, 1, 2], - [variables.sideBarWidth, variables.sideBarWidth + calculateReceiptPaneRHPWidth(windowWidth), windowWidth - variables.navigationTabBarSize - variables.sideBarWithLHBWidth], + [variables.sideBarWidth, variables.sideBarWidth + calculateReceiptPaneRHPWidth(windowWidth), calculateSuperWideRHPWidth(windowWidth)], ); return { diff --git a/src/styles/index.ts b/src/styles/index.ts index 8bca1b5a82a2..b614565d58c5 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -13,7 +13,7 @@ import type {MixedStyleDeclaration, MixedStyleRecord} from 'react-native-render- import type {ValueOf} from 'type-fest'; import type DotLottieAnimation from '@components/LottieAnimations/types'; import {ACTIVE_LABEL_SCALE} from '@components/TextInput/styleConst'; -import {calculateReceiptPaneRHPWidth, receiptPaneRHPWidth} from '@components/WideRHPContextProvider'; +import {calculateReceiptPaneRHPWidth, receiptPaneRHPWidth, superWideRHPWidth} from '@components/WideRHPContextProvider'; import {getBrowser, isMobile, isMobileSafari, isSafari} from '@libs/Browser'; import getPlatform from '@libs/getPlatform'; import CONST from '@src/CONST'; @@ -5354,7 +5354,7 @@ const staticStyles = (theme: ThemeColors) => position: Platform.OS === 'web' ? 'fixed' : 'absolute', height: '100%', right: 0, - width: Animated.subtract(windowWidth, variables.navigationTabBarSize + variables.sideBarWithLHBWidth), + width: superWideRHPWidth, }), flexibleHeight: { diff --git a/src/styles/variables.ts b/src/styles/variables.ts index ad067ed20605..d29541dc0210 100644 --- a/src/styles/variables.ts +++ b/src/styles/variables.ts @@ -102,6 +102,7 @@ export default { androidSafeAreaInsetsPercentage: 1, sideBarWidth: 375, receiptPaneRHPMaxWidth: 465, + superWideRHPMaxWidth: 1260, minScanTooltipWidth: 320, uploadViewMargin: 20, chooseFilesViewMargin: 8, From db1f6a2cd8276e766b78b67dcd9691a7b9dae305 Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Wed, 5 Nov 2025 11:36:34 +0100 Subject: [PATCH 07/64] fixed some errors + small cleanup --- .../WideRHPContextProvider/index.tsx | 22 ------------------- .../Navigators/RightModalNavigator.tsx | 3 +-- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 6fe5b3429663..21f8b67b390b 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -91,20 +91,6 @@ const calculateSuperWideRHPWidth = (windowWidth: number) => { return Math.max(Math.min(SuperWideRHPWidth, variables.superWideRHPMaxWidth), wideRHPWidth); }; -/** - * Calculates the optimal width for the super wide RHP based on window width. - * Ensures the RHP doesn't exceed maximum width and maintains minimum responsive width. - * - * @param windowWidth - Current window width in pixels - * @returns Calculated super wide RHP width with constraints applied - */ -const calculateSuperWideRHPWidth = (windowWidth: number) => { - const SuperWideRHPWidth = windowWidth - variables.navigationTabBarSize - variables.sideBarWithLHBWidth; - const wideRHPWidth = calculateReceiptPaneRHPWidth(windowWidth) + variables.sideBarWidth; - - return Math.max(Math.min(SuperWideRHPWidth, variables.superWideRHPMaxWidth), wideRHPWidth); -}; - // This animated value is necessary to have a responsive RHP width for the range 800px to 840px. const receiptPaneRHPWidth = new Animated.Value(calculateReceiptPaneRHPWidth(Dimensions.get('window').width)); const superWideRHPWidth = new Animated.Value(calculateSuperWideRHPWidth(Dimensions.get('window').width)); @@ -540,24 +526,16 @@ WideRHPContextProvider.displayName = 'WideRHPContextProvider'; export default WideRHPContextProvider; export { - calculateReceiptPaneRHPWidth, calculateSuperWideRHPWidth, - extractNavigationKeys, - receiptPaneRHPWidth, superWideRHPWidth, - wideRHPWidth, modalStackOverlayWideRHPWidth, modalStackOverlaySuperWideRHPWidth, secondOverlayProgress, - useShowSuperWideRHPVersion, - useShowWideRHPVersion, - WideRHPContext, -, }; diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index b74343eebd7b..3a91862c71d0 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -31,7 +31,6 @@ const Stack = createPlatformStackNavigator const singleRHPWidth = variables.sideBarWidth; const getWideRHPWidth = (windowWidth: number) => variables.sideBarWidth + calculateReceiptPaneRHPWidth(windowWidth); -const getSuperWideRHPWidth = (windowWidth: number) => windowWidth - variables.sideBarWithLHBWidth - variables.navigationTabBarSize; function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { const {shouldUseNarrowLayout} = useResponsiveLayout(); @@ -41,7 +40,7 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { const {windowWidth} = useWindowDimensions(); const animatedStyle = useAnimatedStyle(() => { - const width = interpolate(expandedRHPProgress.get(), [0, 1, 2], [singleRHPWidth, getWideRHPWidth(windowWidth), getSuperWideRHPWidth(windowWidth)]); + const width = interpolate(expandedRHPProgress.get(), [0, 1, 2], [singleRHPWidth, getWideRHPWidth(windowWidth), calculateSuperWideRHPWidth(windowWidth)]); return { height: '100%', From 77ea3cf36003462719cb6f282e73a708d772589e Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Wed, 5 Nov 2025 15:41:39 +0100 Subject: [PATCH 08/64] Fix animations when opening rphs --- .../WideRHPContextProvider/index.tsx | 19 +++++++--------- .../WideRHPContextProvider/types.ts | 8 ++++--- .../Navigators/RightModalNavigator.tsx | 18 +++++++-------- .../useRootNavigatorScreenOptions.ts | 22 ++++++++++++++++++- 4 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 469c68aaba02..7e44eaeba718 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -5,7 +5,6 @@ import React, {createContext, useCallback, useContext, useEffect, useMemo, useSt // to interact with react-navigation components (e.g., CardContainer, interpolator), which also use Animated. // eslint-disable-next-line no-restricted-imports import {Animated, Dimensions, InteractionManager} from 'react-native'; -import {useSharedValue} from 'react-native-reanimated'; import useRootNavigationState from '@hooks/useRootNavigationState'; import {isFullScreenName} from '@libs/Navigation/helpers/isNavigatorName'; import navigationRef from '@libs/Navigation/navigationRef'; @@ -17,6 +16,7 @@ import defaultWideRHPContextValue from './default'; import type {WideRHPContextType} from './types'; // 0 is folded/hidden, 1 is expanded/shown +const expandedRHPProgress = new Animated.Value(0); const secondOverlayProgress = new Animated.Value(0); const thirdOverlayProgress = new Animated.Value(0); @@ -90,8 +90,6 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const [shouldRenderThirdOverlay, setShouldRenderThirdOverlay] = useState(false); const [expenseReportIDs, setExpenseReportIDs] = useState>(new Set()); - const expandedRHPProgress = useSharedValue(0); - const focusedRouteKey = useRootNavigationState((state) => findFocusedRoute(state))?.key; // Return undefined if RHP is not the last route @@ -290,13 +288,13 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { */ useEffect(() => { if (superWideRHPRouteKeys.length > 0) { - expandedRHPProgress.set(2); + expandedRHPProgress.setValue(2); } else if (wideRHPRouteKeys.length > 0) { - expandedRHPProgress.set(1); + expandedRHPProgress.setValue(1); } else { - expandedRHPProgress.set(0); + expandedRHPProgress.setValue(0); } - }, [expandedRHPProgress, superWideRHPRouteKeys.length, wideRHPRouteKeys.length]); + }, [superWideRHPRouteKeys.length, wideRHPRouteKeys.length]); /** * Effect that manages the secondary overlay animation and rendering state. @@ -385,7 +383,6 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { isWideRhpFocused, }), [ - expandedRHPProgress, wideRHPRouteKeys, superWideRHPRouteKeys, showWideRHPVersion, @@ -484,12 +481,12 @@ export default WideRHPContextProvider; export { calculateReceiptPaneRHPWidth, extractNavigationKeys, - receiptPaneRHPWidth, - wideRHPWidth, - modalStackOverlayWideRHPWidth, modalStackOverlaySuperWideRHPWidth, + modalStackOverlayWideRHPWidth, + receiptPaneRHPWidth, secondOverlayProgress, useShowSuperWideRHPVersion, useShowWideRHPVersion, WideRHPContext, + wideRHPWidth, }; diff --git a/src/components/WideRHPContextProvider/types.ts b/src/components/WideRHPContextProvider/types.ts index 8d9189d7cb5a..9318e8f10cb8 100644 --- a/src/components/WideRHPContextProvider/types.ts +++ b/src/components/WideRHPContextProvider/types.ts @@ -1,6 +1,5 @@ // eslint-disable-next-line no-restricted-imports import type {Animated} from 'react-native'; -import type {SharedValue} from 'react-native-reanimated'; import type {NavigationRoute} from '@libs/Navigation/types'; type WideRHPContextType = { @@ -10,8 +9,8 @@ type WideRHPContextType = { // Route keys of screens that should be displayed in super wide format superWideRHPRouteKeys: string[]; - // Progress of changing format: 0 - narrow, 1 - wide - expandedRHPProgress: SharedValue; + // Progress of changing format: 0 - narrow, 1 - wide, 2 - super-wide + expandedRHPProgress: Animated.Value; // Progress of the secondary overlay, the one covering wider RHP screen secondOverlayProgress: Animated.Value; @@ -42,6 +41,9 @@ type WideRHPContextType = { // Navigate to the last element in wideRHPRouteKeys array dismissToWideReport: () => void; + + // Whether the currently focused route is inside the wide RHP set + isWideRhpFocused: boolean; }; // eslint-disable-next-line import/prefer-default-export diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index 103325266ce9..d884ba139510 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -1,10 +1,7 @@ import type {NavigatorScreenParams} from '@react-navigation/native'; import React, {useCallback, useContext, useMemo, useRef} from 'react'; -import {InteractionManager} from 'react-native'; -// We use Animated for all functionality related to wide RHP to make it easier -// to interact with react-navigation components (e.g., CardContainer, interpolator), which also use Animated. // eslint-disable-next-line no-restricted-imports -import Animated, {interpolate, useAnimatedStyle} from 'react-native-reanimated'; +import {Animated, InteractionManager} from 'react-native'; import NoDropZone from '@components/DragAndDrop/NoDropZone'; import {calculateReceiptPaneRHPWidth, WideRHPContext, wideRHPWidth} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; @@ -40,17 +37,20 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { const {expandedRHPProgress, shouldRenderSecondaryOverlay, secondOverlayProgress, isWideRhpFocused, shouldRenderThirdOverlay, thirdOverlayProgress} = useContext(WideRHPContext); const {windowWidth} = useWindowDimensions(); - const animatedStyle = useAnimatedStyle(() => { - const width = interpolate(expandedRHPProgress.get(), [0, 1, 2], [singleRHPWidth, getWideRHPWidth(windowWidth), getSuperWideRHPWidth(windowWidth)]); + const animatedWidth = expandedRHPProgress.interpolate({ + inputRange: [0, 1, 2], + outputRange: [singleRHPWidth, getWideRHPWidth(windowWidth), getSuperWideRHPWidth(windowWidth)], + }); + const animatedStyle = useMemo(() => { return { height: '100%', right: 0, position: 'absolute', overflow: 'hidden', - width: shouldUseNarrowLayout ? '100%' : width, - }; - }); + width: shouldUseNarrowLayout ? '100%' : (animatedWidth as unknown as number), + } as const; + }, [animatedWidth, shouldUseNarrowLayout]); const screenListeners = useMemo( () => ({ diff --git a/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts b/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts index 80b837bb2ac0..afc2de926828 100644 --- a/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts +++ b/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts @@ -8,6 +8,7 @@ import {WideRHPContext} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; +import useWindowDimensions from '@hooks/useWindowDimensions'; import Animations from '@libs/Navigation/PlatformStackNavigation/navigationOptions/animation'; import Presentation from '@libs/Navigation/PlatformStackNavigation/navigationOptions/presentation'; import type {PlatformStackNavigationOptions} from '@libs/Navigation/PlatformStackNavigation/types'; @@ -29,6 +30,15 @@ const commonScreenOptions: PlatformStackNavigationOptions = { }, }; +/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument */ +function abs(a: any) { + const b = Animated.multiply(a, -1); + const clampedA = Animated.diffClamp(a, 0, Number.MAX_SAFE_INTEGER); + const clampedB = Animated.diffClamp(b, 0, Number.MAX_SAFE_INTEGER); + + return Animated.add(clampedA, clampedB); +} + const useRootNavigatorScreenOptions = () => { const StyleUtils = useStyleUtils(); const modalCardStyleInterpolator = useModalCardStyleInterpolator(); @@ -36,6 +46,7 @@ const useRootNavigatorScreenOptions = () => { const {isSmallScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout(); const themeStyles = useThemeStyles(); const {expandedRHPProgress} = useContext(WideRHPContext); + const {windowWidth} = useWindowDimensions(); return { rightModalNavigator: { @@ -56,7 +67,16 @@ const useRootNavigatorScreenOptions = () => { // Adjust output range to match the wide RHP size outputRangeMultiplier: isSmallScreenWidth ? undefined - : Animated.add(Animated.multiply(expandedRHPProgress.get(), variables.receiptPaneRHPMaxWidth / variables.sideBarWidth), 1), + : Animated.add( + Animated.add( + Animated.multiply(Animated.subtract(1, abs(Animated.subtract(1, expandedRHPProgress))), variables.receiptPaneRHPMaxWidth / variables.sideBarWidth), + Animated.multiply( + expandedRHPProgress.interpolate({inputRange: [1, 2], outputRange: [0, 1], extrapolate: 'clamp'}), + (windowWidth - variables.navigationTabBarSize - variables.sideBarWithLHBWidth - variables.sideBarWidth) / variables.sideBarWidth, + ), + ), + 1, + ), }), }, }, From fc7a4c2cecf8deb110b3b9c4b0e267b9943e2df0 Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Wed, 5 Nov 2025 16:16:49 +0100 Subject: [PATCH 09/64] added receipt to reports with one transaction in reports tab --- .../MoneyRequestReportView.tsx | 101 +++++++++++------- 1 file changed, 63 insertions(+), 38 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx index 9e816cf999ec..b06e5e3396dc 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx @@ -1,11 +1,15 @@ import {PortalHost} from '@gorhom/portal'; import React, {useCallback, useMemo} from 'react'; -import {InteractionManager, View} from 'react-native'; +// We use Animated for all functionality related to wide RHP to make it easier +// to interact with react-navigation components (e.g., CardContainer, interpolator), which also use Animated. +// eslint-disable-next-line no-restricted-imports +import {Animated, InteractionManager, ScrollView, View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import HeaderGap from '@components/HeaderGap'; import MoneyReportHeader from '@components/MoneyReportHeader'; import MoneyRequestHeader from '@components/MoneyRequestHeader'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import MoneyRequestReceiptView from '@components/ReportActionItem/MoneyRequestReceiptView'; import ReportActionsSkeletonView from '@components/ReportActionsSkeletonView'; import ReportHeaderSkeletonView from '@components/ReportHeaderSkeletonView'; import useNetwork from '@hooks/useNetwork'; @@ -13,6 +17,7 @@ import useNewTransactions from '@hooks/useNewTransactions'; import useOnyx from '@hooks/useOnyx'; import usePaginatedReportActions from '@hooks/usePaginatedReportActions'; import useParentReportAction from '@hooks/useParentReportAction'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import useTransactionsAndViolationsForReport from '@hooks/useTransactionsAndViolationsForReport'; import {removeFailedReport} from '@libs/actions/Report'; @@ -84,6 +89,9 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe const styles = useThemeStyles(); const {isOffline} = useNetwork(); + const {isSmallScreenWidth} = useResponsiveLayout(); + + const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: false}); const reportID = report?.reportID; const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true}); const [isComposerFullSize = false] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE}${reportID}`, {canBeMissing: true}); @@ -129,6 +137,9 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe const isEmptyTransactionReport = visibleTransactions && visibleTransactions.length === 0 && transactionThreadReportID === undefined; const shouldDisplayMoneyRequestActionsList = !!isEmptyTransactionReport || shouldDisplayReportTableView(report, visibleTransactions ?? []); + const [transactionThreadReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`, {canBeMissing: true}); + const shouldShowWideRHPReceipt = visibleTransactions.length === 1 && !isSmallScreenWidth && !!transactionThreadReport; + const reportHeaderView = useMemo( () => isTransactionThreadView ? ( @@ -211,47 +222,61 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe > {reportHeaderView} - - {shouldDisplayMoneyRequestActionsList ? ( - - ) : ( - + + {shouldShowWideRHPReceipt && ( + + + + + )} - {shouldDisplayReportFooter ? ( - <> - + {shouldDisplayMoneyRequestActionsList ? ( + + ) : ( + - - - ) : null} + )} + {shouldDisplayReportFooter ? ( + <> + + + + ) : null} + From 8c773cd69800dd77df9685a565cc6816be8ceb25 Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Wed, 5 Nov 2025 17:06:09 +0100 Subject: [PATCH 10/64] cleanup --- src/components/WideRHPContextProvider/index.tsx | 3 --- .../Navigation/AppNavigator/Navigators/RightModalNavigator.tsx | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 76e54f175479..50f374e7180e 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -526,10 +526,7 @@ export { calculateReceiptPaneRHPWidth, calculateSuperWideRHPWidth, extractNavigationKeys, - receiptPaneRHPWidth, superWideRHPWidth, - wideRHPWidth, - modalStackOverlayWideRHPWidth, modalStackOverlaySuperWideRHPWidth, modalStackOverlayWideRHPWidth, receiptPaneRHPWidth, diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index db2f872bc537..121e52b5af9c 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -27,6 +27,7 @@ type RightModalNavigatorProps = PlatformStackScreenProps(); const singleRHPWidth = variables.sideBarWidth; +const getWideRHPWidth = (windowWidth: number) => variables.sideBarWidth + calculateReceiptPaneRHPWidth(windowWidth); function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { const {shouldUseNarrowLayout} = useResponsiveLayout(); From fb1000f662283b93ab0a2fea02007ca284197d50 Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Thu, 6 Nov 2025 10:15:36 +0100 Subject: [PATCH 11/64] fixed arrow buttons in reports tab --- src/components/WideRHPContextProvider/index.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 50f374e7180e..70c2c4d47422 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -233,6 +233,8 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const newKey = route.key; // If the key is in the array, don't add it. + // Ensure mutual exclusivity: remove key from other array if present + setSuperWideRHPRouteKeys((prev) => (prev.includes(newKey) ? prev.filter((key) => key !== newKey) : prev)); setAllWideRHPRouteKeys((prev) => (prev.includes(newKey) ? prev : [newKey, ...prev])); }, []); @@ -245,6 +247,8 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const newKey = route.key; // If the key is in the array, don't add it. + // Ensure mutual exclusivity: remove key from other array if present + setAllWideRHPRouteKeys((prev) => (prev.includes(newKey) ? prev.filter((key) => key !== newKey) : prev)); setSuperWideRHPRouteKeys((prev) => (prev.includes(newKey) ? prev : [newKey, ...prev])); }, []); From f8d1801f89f668d0aea395953bf0d9ad12860495 Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Thu, 6 Nov 2025 16:03:59 +0100 Subject: [PATCH 12/64] fixed buttons on super wide rhp --- src/components/MoneyReportHeader.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index bc1dabcd30ed..749ccf7af096 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -329,8 +329,8 @@ function MoneyReportHeader({ const {selectedTransactionIDs, removeTransaction, clearSelectedTransactions, currentSearchQueryJSON, currentSearchKey, currentSearchHash} = useSearchContext(); const shouldCalculateTotals = useSearchShouldCalculateTotals(currentSearchKey, currentSearchQueryJSON?.similarSearchHash, true); - const {wideRHPRouteKeys} = useContext(WideRHPContext); - const shouldDisplayNarrowMoreButton = !shouldDisplayNarrowVersion || (wideRHPRouteKeys.length > 0 && !isSmallScreenWidth); + const {wideRHPRouteKeys, superWideRHPRouteKeys} = useContext(WideRHPContext); + const shouldDisplayNarrowMoreButton = !shouldDisplayNarrowVersion || ((wideRHPRouteKeys.length > 0 || superWideRHPRouteKeys.length > 0) && !isSmallScreenWidth); const beginExportWithTemplate = useCallback( (templateName: string, templateType: string, transactionIDList: string[], policyID?: string) => { @@ -1201,7 +1201,7 @@ function MoneyReportHeader({ const showNextStepBar = shouldShowNextStep && !!optimisticNextStep?.message?.length; const showNextStepSkeleton = shouldShowNextStep && !optimisticNextStep && !!isLoadingInitialReportActions && !isOffline; - const shouldShowMoreContent = showNextStepBar || showNextStepSkeleton || !!statusBarProps || isReportInSearch; + const shouldShowMoreContent = showNextStepBar || showNextStepSkeleton || !!statusBarProps || (isReportInSearch && !shouldDisplayNarrowMoreButton); return ( @@ -1241,6 +1241,12 @@ function MoneyReportHeader({ /> )} + {isReportInSearch && ( + + )} )} @@ -1285,7 +1291,7 @@ function MoneyReportHeader({ /> )} - {isReportInSearch && ( + {isReportInSearch && !shouldDisplayNarrowMoreButton && ( Date: Thu, 6 Nov 2025 18:39:07 +0100 Subject: [PATCH 13/64] Adjust overlay widths --- src/components/WideRHPContextProvider/index.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 70c2c4d47422..799f9d0d0f14 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -27,7 +27,6 @@ const thirdOverlayProgress = new Animated.Value(0); const singleRHPWidth = variables.sideBarWidth; const wideRHPMaxWidth = variables.receiptPaneRHPMaxWidth + singleRHPWidth; -const sidebarWidth = variables.sideBarWithLHBWidth + variables.navigationTabBarSize; /** * Utility function that extracts all unique navigation keys from a React Navigation state. @@ -85,10 +84,10 @@ const calculateReceiptPaneRHPWidth = (windowWidth: number) => { * @returns Calculated super wide RHP width with constraints applied */ const calculateSuperWideRHPWidth = (windowWidth: number) => { - const SuperWideRHPWidth = windowWidth - variables.navigationTabBarSize - variables.sideBarWithLHBWidth; + const superWideRHPWidth = windowWidth - variables.navigationTabBarSize - variables.sideBarWithLHBWidth; const wideRHPWidth = calculateReceiptPaneRHPWidth(windowWidth) + variables.sideBarWidth; - return Math.max(Math.min(SuperWideRHPWidth, variables.superWideRHPMaxWidth), wideRHPWidth); + return Math.max(Math.min(superWideRHPWidth, variables.superWideRHPMaxWidth), wideRHPWidth); }; // This animated value is necessary to have a responsive RHP width for the range 800px to 840px. @@ -96,8 +95,10 @@ const receiptPaneRHPWidth = new Animated.Value(calculateReceiptPaneRHPWidth(Dime const superWideRHPWidth = new Animated.Value(calculateSuperWideRHPWidth(Dimensions.get('window').width)); const wideRHPWidth = new Animated.Value(calculateReceiptPaneRHPWidth(Dimensions.get('window').width) + singleRHPWidth); -const modalStackOverlayWideRHPWidth = new Animated.Value(Dimensions.get('window').width - sidebarWidth - calculateReceiptPaneRHPWidth(Dimensions.get('window').width - singleRHPWidth)); -const modalStackOverlaySuperWideRHPWidth = new Animated.Value(Dimensions.get('window').width - sidebarWidth - singleRHPWidth); +const modalStackOverlayWideRHPWidth = new Animated.Value( + calculateSuperWideRHPWidth(Dimensions.get('window').width) - calculateReceiptPaneRHPWidth(Dimensions.get('window').width - singleRHPWidth), +); +const modalStackOverlaySuperWideRHPWidth = new Animated.Value(calculateSuperWideRHPWidth(Dimensions.get('window').width) - singleRHPWidth); const WideRHPContext = createContext(defaultWideRHPContextValue); @@ -398,8 +399,8 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const newWideRHPWidth = newReceiptPaneRHPWidth + singleRHPWidth; receiptPaneRHPWidth.setValue(newReceiptPaneRHPWidth); wideRHPWidth.setValue(newWideRHPWidth); - modalStackOverlayWideRHPWidth.setValue(windowWidth - newWideRHPWidth - sidebarWidth); - modalStackOverlaySuperWideRHPWidth.setValue(windowWidth - sidebarWidth - singleRHPWidth); + modalStackOverlayWideRHPWidth.setValue(newSuperWideRHPWidth - newWideRHPWidth); + modalStackOverlaySuperWideRHPWidth.setValue(newSuperWideRHPWidth - singleRHPWidth); superWideRHPWidth.setValue(newSuperWideRHPWidth); }; From 5261d348c8aa2ffff2507e820a94c189976d6d33 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Fri, 7 Nov 2025 09:44:54 +0100 Subject: [PATCH 14/64] Fix animations --- .../WideRHPContextProvider/index.tsx | 8 +++++++ .../Navigators/RightModalNavigator.tsx | 23 +++++++++++++++++-- .../useRootNavigatorScreenOptions.ts | 4 ++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 799f9d0d0f14..d5b03b82a0e3 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -22,6 +22,7 @@ import type {WideRHPContextType} from './types'; // 0 is folded/hidden, 1 is expanded/shown const expandedRHPProgress = new Animated.Value(0); +const innerRHPProgress = new Animated.Value(0); const secondOverlayProgress = new Animated.Value(0); const thirdOverlayProgress = new Animated.Value(0); @@ -336,10 +337,16 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { useEffect(() => { if (superWideRHPRouteKeys.length > 0) { expandedRHPProgress.setValue(2); + if (wideRHPRouteKeys.length > 0) { + innerRHPProgress.setValue(1); + } else { + innerRHPProgress.setValue(0); + } } else if (wideRHPRouteKeys.length > 0) { expandedRHPProgress.setValue(1); } else { expandedRHPProgress.setValue(0); + innerRHPProgress.setValue(0); } }, [superWideRHPRouteKeys.length, wideRHPRouteKeys.length]); @@ -540,4 +547,5 @@ export { useShowWideRHPVersion, WideRHPContext, wideRHPWidth, + innerRHPProgress, }; diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index 121e52b5af9c..1a5e13c59a31 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -1,18 +1,21 @@ import type {NavigatorScreenParams} from '@react-navigation/native'; +import type {StackCardInterpolationProps} from '@react-navigation/stack'; import React, {useCallback, useContext, useMemo, useRef} from 'react'; // eslint-disable-next-line no-restricted-imports import {Animated, InteractionManager} from 'react-native'; import NoDropZone from '@components/DragAndDrop/NoDropZone'; -import {calculateReceiptPaneRHPWidth, calculateSuperWideRHPWidth, WideRHPContext, wideRHPWidth} from '@components/WideRHPContextProvider'; +import {calculateReceiptPaneRHPWidth, calculateSuperWideRHPWidth, innerRHPProgress, WideRHPContext, wideRHPWidth} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useWindowDimensions from '@hooks/useWindowDimensions'; import {abandonReviewDuplicateTransactions} from '@libs/actions/Transaction'; import {clearTwoFactorAuthData} from '@libs/actions/TwoFactorAuthActions'; import hideKeyboardOnSwipe from '@libs/Navigation/AppNavigator/hideKeyboardOnSwipe'; import * as ModalStackNavigators from '@libs/Navigation/AppNavigator/ModalStackNavigators'; +import useModalCardStyleInterpolator from '@libs/Navigation/AppNavigator/useModalCardStyleInterpolator'; import useRHPScreenOptions from '@libs/Navigation/AppNavigator/useRHPScreenOptions'; import Navigation from '@libs/Navigation/Navigation'; import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; +import Presentation from '@libs/Navigation/PlatformStackNavigation/navigationOptions/presentation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {AuthScreensParamList, RightModalNavigatorParamList} from '@navigation/types'; import variables from '@styles/variables'; @@ -30,11 +33,12 @@ const singleRHPWidth = variables.sideBarWidth; const getWideRHPWidth = (windowWidth: number) => variables.sideBarWidth + calculateReceiptPaneRHPWidth(windowWidth); function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { - const {shouldUseNarrowLayout} = useResponsiveLayout(); + const {shouldUseNarrowLayout, isSmallScreenWidth} = useResponsiveLayout(); const isExecutingRef = useRef(false); const screenOptions = useRHPScreenOptions(); const {expandedRHPProgress, shouldRenderSecondaryOverlay, secondOverlayProgress, isWideRhpFocused, shouldRenderThirdOverlay, thirdOverlayProgress} = useContext(WideRHPContext); const {windowWidth} = useWindowDimensions(); + const modalCardStyleInterpolator = useModalCardStyleInterpolator(); const animatedWidth = expandedRHPProgress.interpolate({ inputRange: [0, 1, 2], @@ -249,6 +253,21 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { + // Add 1 to change range from [0, 1] to [1, 2] + // Don't use outputMultiplier for the narrow layout + modalCardStyleInterpolator({ + props, + shouldAnimateSidePanel: true, + + // Adjust output range to match the wide RHP size + outputRangeMultiplier: isSmallScreenWidth + ? undefined + : Animated.add(Animated.multiply(innerRHPProgress, variables.receiptPaneRHPMaxWidth / variables.sideBarWidth), 1), + }), + }} /> { Animated.multiply(Animated.subtract(1, abs(Animated.subtract(1, expandedRHPProgress))), variables.receiptPaneRHPMaxWidth / variables.sideBarWidth), Animated.multiply( expandedRHPProgress.interpolate({inputRange: [1, 2], outputRange: [0, 1], extrapolate: 'clamp'}), - (windowWidth - variables.navigationTabBarSize - variables.sideBarWithLHBWidth - variables.sideBarWidth) / variables.sideBarWidth, + (calculateSuperWideRHPWidth(windowWidth) - variables.sideBarWidth) / variables.sideBarWidth, ), ), 1, From 00c8d0fbb68fef456386b5435c4897790f5eb9d5 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Fri, 7 Nov 2025 13:35:41 +0100 Subject: [PATCH 15/64] Fix navigating to second swrhp --- src/components/WideRHPContextProvider/index.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index d5b03b82a0e3..b7f8023272b8 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -185,6 +185,11 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { return false; } + // This screen is always first in RHP, so secondary overlay is not displayed in this case. + if (focusedRoute.name === SCREENS.SEARCH.MONEY_REQUEST_REPORT) { + return false; + } + if (superWideRHPRouteKeys.includes(focusedRoute.key) && wideRHPRouteKeys.length > 0) { return false; } From bc0e1370687663def04686a35e6693c359cd612c Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Wed, 12 Nov 2025 15:43:39 +0100 Subject: [PATCH 16/64] Fix showing secondary overlay --- .../Navigation/AppNavigator/ModalStackNavigators/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index ce8c10ef28f7..8e8d98fdb4eb 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -94,7 +94,7 @@ function createModalStackNavigator(screens: Scr function ModalStack() { const styles = useThemeStyles(); const screenOptions = useModalStackScreenOptions(); - const {secondOverlayProgress, shouldRenderSecondaryOverlay, thirdOverlayProgress, shouldRenderThirdOverlay, isWideRhpFocused} = useContext(WideRHPContext); + const {secondOverlayProgress, shouldRenderSecondaryOverlay, thirdOverlayProgress, shouldRenderThirdOverlay, isWideRhpFocused, superWideRHPRouteKeys} = useContext(WideRHPContext); const route = useRoute(); const isFocused = useIsFocused(); @@ -144,7 +144,7 @@ function createModalStackNavigator(screens: Scr {!isSmallScreenWidth && shouldRenderSecondaryOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT && !isWideRhpFocused && !isFocused ? ( 0 ? modalStackOverlaySuperWideRHPWidth : receiptPaneRHPWidth} /> ) : null} {!isSmallScreenWidth && shouldRenderThirdOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT ? ( From d3d3e8db762c581ed8c9177cf1d51859cd9b1370 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Thu, 13 Nov 2025 12:31:33 +0100 Subject: [PATCH 17/64] Fix flickering overlay --- src/components/WideRHPContextProvider/index.tsx | 13 +++++++++---- .../AppNavigator/ModalStackNavigators/index.tsx | 5 +++-- .../AppNavigator/Navigators/RightModalNavigator.tsx | 7 ++++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index b7f8023272b8..0a16b765cceb 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -123,7 +123,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const [shouldRenderSecondaryOverlay, setShouldRenderSecondaryOverlay] = useState(false); const [shouldRenderThirdOverlay, setShouldRenderThirdOverlay] = useState(false); const [expenseReportIDs, setExpenseReportIDs] = useState>(new Set()); - + const [isWideRHPClosing, setIsWideRHPClosing] = useState(false); const focusedRouteKey = useRootNavigationState((state) => findFocusedRoute(state))?.key; const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {selector: expenseReportSelector, canBeMissing: true}); @@ -252,7 +252,6 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { } const newKey = route.key; - // If the key is in the array, don't add it. // Ensure mutual exclusivity: remove key from other array if present setAllWideRHPRouteKeys((prev) => (prev.includes(newKey) ? prev.filter((key) => key !== newKey) : prev)); @@ -442,6 +441,8 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { markReportIDAsExpense, isReportIDMarkedAsExpense, isWideRhpFocused, + isWideRHPClosing, + setIsWideRHPClosing, }), [ wideRHPRouteKeys, @@ -455,6 +456,8 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { markReportIDAsExpense, isReportIDMarkedAsExpense, isWideRhpFocused, + isWideRHPClosing, + setIsWideRHPClosing, ], ); @@ -472,7 +475,7 @@ function useShowWideRHPVersion(condition: boolean) { const navigation = useNavigation(); const route = useRoute(); const reportID = route.params && 'reportID' in route.params && typeof route.params.reportID === 'string' ? route.params.reportID : ''; - const {showWideRHPVersion, cleanWideRHPRouteKey, isReportIDMarkedAsExpense} = useContext(WideRHPContext); + const {showWideRHPVersion, cleanWideRHPRouteKey, isReportIDMarkedAsExpense, setIsWideRHPClosing} = useContext(WideRHPContext); /** * Effect that sets up cleanup when the screen is about to be removed. @@ -480,12 +483,14 @@ function useShowWideRHPVersion(condition: boolean) { */ useEffect(() => { return navigation.addListener('beforeRemove', () => { + setIsWideRHPClosing(true); // eslint-disable-next-line @typescript-eslint/no-deprecated InteractionManager.runAfterInteractions(() => { cleanWideRHPRouteKey(route); + setIsWideRHPClosing(false); }); }); - }, [cleanWideRHPRouteKey, navigation, route]); + }, [cleanWideRHPRouteKey, navigation, route, setIsWideRHPClosing]); /** * Effect that determines whether to show wide RHP based on condition or optimistic state. diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 8e8d98fdb4eb..ebc9c56ed0b3 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -94,7 +94,8 @@ function createModalStackNavigator(screens: Scr function ModalStack() { const styles = useThemeStyles(); const screenOptions = useModalStackScreenOptions(); - const {secondOverlayProgress, shouldRenderSecondaryOverlay, thirdOverlayProgress, shouldRenderThirdOverlay, isWideRhpFocused, superWideRHPRouteKeys} = useContext(WideRHPContext); + const {secondOverlayProgress, shouldRenderSecondaryOverlay, thirdOverlayProgress, shouldRenderThirdOverlay, isWideRhpFocused, superWideRHPRouteKeys, isWideRHPClosing} = + useContext(WideRHPContext); const route = useRoute(); const isFocused = useIsFocused(); @@ -128,7 +129,7 @@ function createModalStackNavigator(screens: Scr /> ))} - {!isSmallScreenWidth && shouldRenderSecondaryOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT && !isFocused && !shouldRenderThirdOverlay ? ( + {!isSmallScreenWidth && shouldRenderSecondaryOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT && !isFocused && !isWideRHPClosing && !shouldRenderThirdOverlay ? ( // This overlay is necessary to cover the gap under the narrow format RHP screen (false); const screenOptions = useRHPScreenOptions(); - const {expandedRHPProgress, shouldRenderSecondaryOverlay, secondOverlayProgress, isWideRhpFocused, shouldRenderThirdOverlay, thirdOverlayProgress} = useContext(WideRHPContext); + const {expandedRHPProgress, shouldRenderSecondaryOverlay, secondOverlayProgress, isWideRhpFocused, shouldRenderThirdOverlay, thirdOverlayProgress, isWideRHPClosing} = + useContext(WideRHPContext); const {windowWidth} = useWindowDimensions(); const modalCardStyleInterpolator = useModalCardStyleInterpolator(); @@ -86,7 +87,7 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { isExecutingRef.current = false; }, CONST.ANIMATED_TRANSITION); }, [navigation]); - + console.log('isWideRHPFocused', {isWideRHPClosing, isWideRhpFocused}); return ( @@ -301,7 +302,7 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { {/* The second overlay is here to cover the wide rhp screen underneath */} {/* It has a gap on the right to make the last rhp route (narrow) visible and pressable */} - {shouldRenderSecondaryOverlay && !shouldUseNarrowLayout && !isWideRhpFocused && ( + {shouldRenderSecondaryOverlay && !shouldUseNarrowLayout && !isWideRhpFocused && !isWideRHPClosing && ( Date: Thu, 13 Nov 2025 18:02:23 +0100 Subject: [PATCH 18/64] Fix showing overlay when navigating back from Inbox --- .../WideRHPContextProvider/index.tsx | 99 +++++++++++-------- 1 file changed, 57 insertions(+), 42 deletions(-) diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 0a16b765cceb..1e8b01b21bef 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -10,7 +10,7 @@ import useOnyx from '@hooks/useOnyx'; import useRootNavigationState from '@hooks/useRootNavigationState'; import {isFullScreenName} from '@libs/Navigation/helpers/isNavigatorName'; import navigationRef from '@libs/Navigation/navigationRef'; -import type {NavigationRoute} from '@libs/Navigation/types'; +import type {NavigationRoute, RootNavigatorParamList} from '@libs/Navigation/types'; import variables from '@styles/variables'; import CONST from '@src/CONST'; import NAVIGATORS from '@src/NAVIGATORS'; @@ -115,11 +115,46 @@ const expenseReportSelector = (reports: OnyxCollection) => { ); }; +function getCurrentWideRHPKeys(allWideRHPKeys: string[], lastVisibleRHPRouteKey: string | undefined) { + const rootState = navigationRef.getRootState(); + + if (!rootState) { + return []; + } + + const lastRHPRoute = rootState.routes.find((route) => route.key === lastVisibleRHPRouteKey); + + if (!lastRHPRoute) { + return []; + } + + const lastRHPKeys = extractNavigationKeys(lastRHPRoute.state); + const currentKeys = allWideRHPKeys.filter((key) => lastRHPKeys.has(key)); + + return currentKeys; +} + +function getLastVisibleRHPRouteKey(state: NavigationState) { + // Safe handling when navigation is not yet initialized + if (!state) { + return undefined; + } + const lastFullScreenRouteIndex = state?.routes.findLastIndex((route) => isFullScreenName(route.name)); + const lastRHPRouteIndex = state?.routes.findLastIndex((route) => route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR); + + // Both routes have to be present and the RHP have to be after last full screen for it to be visible. + if (lastFullScreenRouteIndex === -1 || lastRHPRouteIndex === -1 || lastFullScreenRouteIndex > lastRHPRouteIndex) { + return undefined; + } + + return state?.routes.at(lastRHPRouteIndex)?.key; +} + function WideRHPContextProvider({children}: React.PropsWithChildren) { // We have a separate containers for allWideRHPRouteKeys and wideRHPRouteKeys because we may have two or more RHPs on the stack. // For convenience and proper overlay logic wideRHPRouteKeys will show only the keys existing in the last RHP. const [allWideRHPRouteKeys, setAllWideRHPRouteKeys] = useState([]); - const [superWideRHPRouteKeys, setSuperWideRHPRouteKeys] = useState([]); + const [allSuperWideRHPRouteKeys, setAllSuperWideRHPRouteKeys] = useState([]); const [shouldRenderSecondaryOverlay, setShouldRenderSecondaryOverlay] = useState(false); const [shouldRenderThirdOverlay, setShouldRenderThirdOverlay] = useState(false); const [expenseReportIDs, setExpenseReportIDs] = useState>(new Set()); @@ -128,40 +163,10 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {selector: expenseReportSelector, canBeMissing: true}); // Return undefined if RHP is not the last route - const lastVisibleRHPRouteKey = useRootNavigationState((state) => { - // Safe handling when navigation is not yet initialized - if (!state) { - return undefined; - } - const lastFullScreenRouteIndex = state?.routes.findLastIndex((route) => isFullScreenName(route.name)); - const lastRHPRouteIndex = state?.routes.findLastIndex((route) => route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR); - - // Both routes have to be present and the RHP have to be after last full screen for it to be visible. - if (lastFullScreenRouteIndex === -1 || lastRHPRouteIndex === -1 || lastFullScreenRouteIndex > lastRHPRouteIndex) { - return undefined; - } - - return state?.routes.at(lastRHPRouteIndex)?.key; - }); - - const wideRHPRouteKeys = useMemo(() => { - const rootState = navigationRef.getRootState(); - - if (!rootState) { - return []; - } - - const lastRHPRoute = rootState.routes.find((route) => route.key === lastVisibleRHPRouteKey); - - if (!lastRHPRoute) { - return []; - } - - const lastRHPKeys = extractNavigationKeys(lastRHPRoute.state); - const currentKeys = allWideRHPRouteKeys.filter((key) => lastRHPKeys.has(key)); + const lastVisibleRHPRouteKey = useRootNavigationState((state) => getLastVisibleRHPRouteKey(state)); - return currentKeys; - }, [allWideRHPRouteKeys, lastVisibleRHPRouteKey]); + const wideRHPRouteKeys = useMemo(() => getCurrentWideRHPKeys(allWideRHPRouteKeys, lastVisibleRHPRouteKey), [allWideRHPRouteKeys, lastVisibleRHPRouteKey]); + const superWideRHPRouteKeys = useMemo(() => getCurrentWideRHPKeys(allSuperWideRHPRouteKeys, lastVisibleRHPRouteKey), [allSuperWideRHPRouteKeys, lastVisibleRHPRouteKey]); const isWideRhpFocused = useMemo(() => { return focusedRouteKey && wideRHPRouteKeys.includes(focusedRouteKey); @@ -179,6 +184,9 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const focusedRoute = findFocusedRoute(state); const isRHPLastRootRoute = state?.routes.at(-1)?.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR; + const currentLastVisibleRHPRouteKey = getLastVisibleRHPRouteKey(state); + const currentWideRHPRouteKeys = getCurrentWideRHPKeys(allWideRHPRouteKeys, currentLastVisibleRHPRouteKey); + const currentSuperWideRHPRouteKeys = getCurrentWideRHPKeys(allSuperWideRHPRouteKeys, currentLastVisibleRHPRouteKey); // Shouldn't ever happen but for type safety if (!focusedRoute?.key) { @@ -190,16 +198,21 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { return false; } - if (superWideRHPRouteKeys.includes(focusedRoute.key) && wideRHPRouteKeys.length > 0) { + if (currentSuperWideRHPRouteKeys.includes(focusedRoute.key) && currentWideRHPRouteKeys.length > 0) { return false; } - if (superWideRHPRouteKeys.length > 0 && !superWideRHPRouteKeys.includes(focusedRoute.key) && isRHPLastRootRoute && focusedRoute.name !== SCREENS.SEARCH.MONEY_REQUEST_REPORT) { + if ( + currentSuperWideRHPRouteKeys.length > 0 && + !currentSuperWideRHPRouteKeys.includes(focusedRoute.key) && + isRHPLastRootRoute && + focusedRoute.name !== SCREENS.SEARCH.MONEY_REQUEST_REPORT + ) { return true; } // Check the focused route to avoid glitching when quickly close and open RHP. - if (wideRHPRouteKeys.length > 0 && !wideRHPRouteKeys.includes(focusedRoute.key) && isRHPLastRootRoute && focusedRoute.name !== SCREENS.SEARCH.REPORT_RHP) { + if (currentWideRHPRouteKeys.length > 0 && !currentWideRHPRouteKeys.includes(focusedRoute.key) && isRHPLastRootRoute && focusedRoute.name !== SCREENS.SEARCH.REPORT_RHP) { return true; } @@ -214,6 +227,8 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const focusedRoute = findFocusedRoute(state); const isRHPLastRootRoute = state?.routes.at(-1)?.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR; + const currentLastVisibleRHPRouteKey = getLastVisibleRHPRouteKey(state); + const currentSuperWideRHPRouteKeys = getCurrentWideRHPKeys(allSuperWideRHPRouteKeys, currentLastVisibleRHPRouteKey); // Shouldn't ever happen but for type safety if (!focusedRoute?.key) { @@ -221,7 +236,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { } const isSuperWideRhpDisplayedBelow = - superWideRHPRouteKeys.length > 0 && !superWideRHPRouteKeys.includes(focusedRoute.key) && focusedRoute.name !== SCREENS.SEARCH.MONEY_REQUEST_REPORT; + currentSuperWideRHPRouteKeys.length > 0 && !currentSuperWideRHPRouteKeys.includes(focusedRoute.key) && focusedRoute.name !== SCREENS.SEARCH.MONEY_REQUEST_REPORT; const isWideRhpDisplayedBelow = wideRHPRouteKeys.length > 0 && !wideRHPRouteKeys.includes(focusedRoute.key) && focusedRoute.name !== SCREENS.SEARCH.REPORT_RHP; // Check the focused route to avoid glitching when quickly close and open RHP. @@ -241,7 +256,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { // If the key is in the array, don't add it. // Ensure mutual exclusivity: remove key from other array if present - setSuperWideRHPRouteKeys((prev) => (prev.includes(newKey) ? prev.filter((key) => key !== newKey) : prev)); + setAllSuperWideRHPRouteKeys((prev) => (prev.includes(newKey) ? prev.filter((key) => key !== newKey) : prev)); setAllWideRHPRouteKeys((prev) => (prev.includes(newKey) ? prev : [newKey, ...prev])); }, []); @@ -255,7 +270,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { // If the key is in the array, don't add it. // Ensure mutual exclusivity: remove key from other array if present setAllWideRHPRouteKeys((prev) => (prev.includes(newKey) ? prev.filter((key) => key !== newKey) : prev)); - setSuperWideRHPRouteKeys((prev) => (prev.includes(newKey) ? prev : [newKey, ...prev])); + setAllSuperWideRHPRouteKeys((prev) => (prev.includes(newKey) ? prev : [newKey, ...prev])); }, []); /** @@ -276,7 +291,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { } setAllWideRHPRouteKeys((prev) => (prev.includes(keyToRemove) ? prev.filter((key) => key !== keyToRemove) : prev)); - setSuperWideRHPRouteKeys((prev) => (prev.includes(keyToRemove) ? prev.filter((key) => key !== keyToRemove) : prev)); + setAllSuperWideRHPRouteKeys((prev) => (prev.includes(keyToRemove) ? prev.filter((key) => key !== keyToRemove) : prev)); }, [allWideRHPRouteKeys, superWideRHPRouteKeys], ); From d895eaeac16e024dfef7a90f58e12a5e9558b597 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Thu, 13 Nov 2025 19:49:50 +0100 Subject: [PATCH 19/64] Fix navigating back after deleting expense --- src/pages/home/ReportScreen.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index c59ea91d12e3..bbb3b5e07bc0 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -2,7 +2,7 @@ import {PortalHost} from '@gorhom/portal'; import {useIsFocused} from '@react-navigation/native'; import {accountIDSelector} from '@selectors/Session'; import {deepEqual} from 'fast-equals'; -import React, {memo, useCallback, useEffect, useMemo, useRef, useState} from 'react'; +import React, {memo, useCallback, useContext, useEffect, useMemo, useRef, useState} from 'react'; import type {FlatList, ViewStyle} from 'react-native'; // We use Animated for all functionality related to wide RHP to make it easier // to interact with react-navigation components (e.g., CardContainer, interpolator), which also use Animated. @@ -21,7 +21,7 @@ import MoneyRequestReceiptView from '@components/ReportActionItem/MoneyRequestRe import ReportActionsSkeletonView from '@components/ReportActionsSkeletonView'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; -import {useShowWideRHPVersion} from '@components/WideRHPContextProvider'; +import {useShowWideRHPVersion, WideRHPContext} from '@components/WideRHPContextProvider'; import useAppFocusEvent from '@hooks/useAppFocusEvent'; import useCurrentReportID from '@hooks/useCurrentReportID'; import useDeepCompareRef from '@hooks/useDeepCompareRef'; @@ -163,6 +163,9 @@ function ReportScreen({route, navigation}: ReportScreenProps) { const {isBetaEnabled} = usePermissions(); const {isOffline} = useNetwork(); const {shouldUseNarrowLayout, isInNarrowPaneModal} = useResponsiveLayout(); + + const {wideRHPRouteKeys, superWideRHPRouteKeys} = useContext(WideRHPContext); + const isDisplayedInWidePaneModal = wideRHPRouteKeys.includes(route.key) || superWideRHPRouteKeys.includes(route.key); const currentReportIDValue = useCurrentReportID(); const [isComposerFullSize = false] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE}${reportIDFromRoute}`, {canBeMissing: true}); @@ -371,7 +374,7 @@ function ReportScreen({route, navigation}: ReportScreenProps) { Navigation.goBack(); return; } - if (prioritizeBackTo && backTo) { + if ((prioritizeBackTo && backTo) || isDisplayedInWidePaneModal) { Navigation.goBack(backTo as Route); return; } @@ -389,7 +392,7 @@ function ReportScreen({route, navigation}: ReportScreenProps) { } Navigation.goBack(); }, - [isInNarrowPaneModal, backTo], + [isInNarrowPaneModal, isDisplayedInWidePaneModal, backTo], ); let headerView = ( From c017a39d527d7eea8b01cb0565654a782008ccff Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Fri, 14 Nov 2025 11:48:53 +0100 Subject: [PATCH 20/64] Adjust WideRHPContextType types --- src/components/WideRHPContextProvider/types.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/WideRHPContextProvider/types.ts b/src/components/WideRHPContextProvider/types.ts index 9318e8f10cb8..de90dcc42c23 100644 --- a/src/components/WideRHPContextProvider/types.ts +++ b/src/components/WideRHPContextProvider/types.ts @@ -43,7 +43,13 @@ type WideRHPContextType = { dismissToWideReport: () => void; // Whether the currently focused route is inside the wide RHP set - isWideRhpFocused: boolean; + isWideRHPFocused: boolean; + + // Whether the wide rhp modal is closing + isWideRHPClosing: boolean; + + // Mark that wide rhp is being closed + setIsWideRHPClosing: (isClosing: boolean) => void }; // eslint-disable-next-line import/prefer-default-export From bd95c582e00afb89e931e6989c69930ba034874e Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Fri, 14 Nov 2025 12:27:57 +0100 Subject: [PATCH 21/64] Add expense report rhp page --- src/ROUTES.ts | 11 ++++++++++ src/SCREENS.ts | 2 ++ .../MoneyRequestReportPreviewContent.tsx | 2 +- .../MoneyRequestReportPreview/index.tsx | 2 +- .../WideRHPContextProvider/index.tsx | 20 ++++++++----------- .../ModalStackNavigators/index.tsx | 20 ++++++++++++------- .../Navigators/RightModalNavigator.tsx | 12 +++++++---- .../Navigation/helpers/isWideRHPRouteName.ts | 11 ++++++++++ src/libs/Navigation/linkingConfig/config.ts | 5 +++++ src/libs/Navigation/types.ts | 10 ++++++++++ .../Search/SearchMoneyRequestReportPage.tsx | 6 ++++-- 11 files changed, 74 insertions(+), 27 deletions(-) create mode 100644 src/libs/Navigation/helpers/isWideRHPRouteName.ts diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 44ff6908fd2f..52979bc13fa8 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -83,6 +83,17 @@ const ROUTES = { return getUrlWithBackToParam(baseRoute, backTo); }, }, + + EXPENSE_REPORT_RHP: { + route: 'e/:reportID', + getRoute: ({reportID, backTo}: {reportID: string; backTo?: string}) => { + const baseRoute = `e/${reportID}` as const; + + // eslint-disable-next-line no-restricted-syntax -- Legacy route generation + return getUrlWithBackToParam(baseRoute, backTo); + }, + }, + SEARCH_MONEY_REQUEST_REPORT: { route: 'search/r/:reportID', getRoute: ({reportID, backTo}: {reportID: string; backTo?: string}) => { diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 9281f6276134..938f79205456 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -255,7 +255,9 @@ const SCREENS = { SCHEDULE_CALL: 'ScheduleCall', REPORT_CHANGE_APPROVER: 'Report_Change_Approver', MERGE_TRANSACTION: 'MergeTransaction', + EXPENSE_REPORT: 'ExpenseReport', }, + EXPENSE_REPORT_RHP: 'Expense_Report_RHP', PUBLIC_CONSOLE_DEBUG: 'Console_Debug', SIGN_IN_WITH_APPLE_DESKTOP: 'AppleSignInDesktop', SIGN_IN_WITH_GOOGLE_DESKTOP: 'GoogleSignInDesktop', diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index f9d905d1b037..7b6211247253 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -476,7 +476,7 @@ function MoneyRequestReportPreviewContent({ } Performance.markStart(CONST.TIMING.OPEN_REPORT_FROM_PREVIEW); Timing.start(CONST.TIMING.OPEN_REPORT_FROM_PREVIEW); - Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(iouReportID, undefined, undefined, Navigation.getActiveRoute())); + Navigation.navigate(ROUTES.EXPENSE_REPORT_RHP.getRoute({reportID: iouReportID, backTo: Navigation.getActiveRoute()})); }, [iouReportID]); const reportPreviewAction = useMemo(() => { diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx index d9cceea897a7..bb4a57719a70 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx @@ -106,7 +106,7 @@ function MoneyRequestReportPreview({ Performance.markStart(CONST.TIMING.OPEN_REPORT_FROM_PREVIEW); Timing.start(CONST.TIMING.OPEN_REPORT_FROM_PREVIEW); - Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(iouReportID, undefined, undefined, Navigation.getActiveRoute())); + Navigation.navigate(ROUTES.EXPENSE_REPORT_RHP.getRoute({reportID: iouReportID, backTo: Navigation.getActiveRoute()})); }, [iouReportID]); const renderItem: ListRenderItem = ({item}) => ( diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 1e8b01b21bef..c00356bd4ec8 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -9,6 +9,7 @@ import type {OnyxCollection} from 'react-native-onyx'; import useOnyx from '@hooks/useOnyx'; import useRootNavigationState from '@hooks/useRootNavigationState'; import {isFullScreenName} from '@libs/Navigation/helpers/isNavigatorName'; +import {isSuperWideRHPRouteName} from '@libs/Navigation/helpers/isWideRHPRouteName'; import navigationRef from '@libs/Navigation/navigationRef'; import type {NavigationRoute, RootNavigatorParamList} from '@libs/Navigation/types'; import variables from '@styles/variables'; @@ -168,8 +169,8 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const wideRHPRouteKeys = useMemo(() => getCurrentWideRHPKeys(allWideRHPRouteKeys, lastVisibleRHPRouteKey), [allWideRHPRouteKeys, lastVisibleRHPRouteKey]); const superWideRHPRouteKeys = useMemo(() => getCurrentWideRHPKeys(allSuperWideRHPRouteKeys, lastVisibleRHPRouteKey), [allSuperWideRHPRouteKeys, lastVisibleRHPRouteKey]); - const isWideRhpFocused = useMemo(() => { - return focusedRouteKey && wideRHPRouteKeys.includes(focusedRouteKey); + const isWideRHPFocused = useMemo(() => { + return !!focusedRouteKey && wideRHPRouteKeys.includes(focusedRouteKey); }, [focusedRouteKey, wideRHPRouteKeys]); /** @@ -194,7 +195,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { } // This screen is always first in RHP, so secondary overlay is not displayed in this case. - if (focusedRoute.name === SCREENS.SEARCH.MONEY_REQUEST_REPORT) { + if (isSuperWideRHPRouteName(focusedRoute.name)) { return false; } @@ -202,12 +203,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { return false; } - if ( - currentSuperWideRHPRouteKeys.length > 0 && - !currentSuperWideRHPRouteKeys.includes(focusedRoute.key) && - isRHPLastRootRoute && - focusedRoute.name !== SCREENS.SEARCH.MONEY_REQUEST_REPORT - ) { + if (currentSuperWideRHPRouteKeys.length > 0 && !currentSuperWideRHPRouteKeys.includes(focusedRoute.key) && isRHPLastRootRoute && !isSuperWideRHPRouteName(focusedRoute.name)) { return true; } @@ -236,7 +232,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { } const isSuperWideRhpDisplayedBelow = - currentSuperWideRHPRouteKeys.length > 0 && !currentSuperWideRHPRouteKeys.includes(focusedRoute.key) && focusedRoute.name !== SCREENS.SEARCH.MONEY_REQUEST_REPORT; + currentSuperWideRHPRouteKeys.length > 0 && !currentSuperWideRHPRouteKeys.includes(focusedRoute.key) && !isSuperWideRHPRouteName(focusedRoute.name); const isWideRhpDisplayedBelow = wideRHPRouteKeys.length > 0 && !wideRHPRouteKeys.includes(focusedRoute.key) && focusedRoute.name !== SCREENS.SEARCH.REPORT_RHP; // Check the focused route to avoid glitching when quickly close and open RHP. @@ -455,7 +451,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { dismissToWideReport, markReportIDAsExpense, isReportIDMarkedAsExpense, - isWideRhpFocused, + isWideRHPFocused, isWideRHPClosing, setIsWideRHPClosing, }), @@ -470,7 +466,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { dismissToWideReport, markReportIDAsExpense, isReportIDMarkedAsExpense, - isWideRhpFocused, + isWideRHPFocused, isWideRHPClosing, setIsWideRHPClosing, ], diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index ebc9c56ed0b3..c0373d638e86 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -2,10 +2,11 @@ import {useIsFocused, useRoute} from '@react-navigation/native'; import type {ParamListBase} from '@react-navigation/routers'; import React, {useCallback, useContext} from 'react'; import {View} from 'react-native'; -import {modalStackOverlaySuperWideRHPWidth, modalStackOverlayWideRHPWidth, receiptPaneRHPWidth, WideRHPContext, wideRHPWidth} from '@components/WideRHPContextProvider'; +import {modalStackOverlaySuperWideRHPWidth, modalStackOverlayWideRHPWidth, receiptPaneRHPWidth, WideRHPContext} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import Overlay from '@libs/Navigation/AppNavigator/Navigators/Overlay'; +import {isSuperWideRHPRouteName, isWideRHPRouteName} from '@libs/Navigation/helpers/isWideRHPRouteName'; import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; import Animations from '@libs/Navigation/PlatformStackNavigation/navigationOptions/animation'; import type {PlatformStackNavigationOptions} from '@libs/Navigation/PlatformStackNavigation/types'; @@ -16,6 +17,7 @@ import type { DebugParamList, EditRequestNavigatorParamList, EnablePaymentsNavigatorParamList, + ExpenseReportNavigatorParamList, FlagCommentNavigatorParamList, MergeTransactionNavigatorParamList, MissingPersonalDetailsParamList, @@ -51,7 +53,6 @@ import type { WorkspaceConfirmationNavigatorParamList, WorkspaceDuplicateNavigatorParamList, } from '@navigation/types'; -import variables from '@styles/variables'; import type {Screen} from '@src/SCREENS'; import SCREENS from '@src/SCREENS'; import type ReactComponentModule from '@src/types/utils/ReactComponentModule'; @@ -94,7 +95,7 @@ function createModalStackNavigator(screens: Scr function ModalStack() { const styles = useThemeStyles(); const screenOptions = useModalStackScreenOptions(); - const {secondOverlayProgress, shouldRenderSecondaryOverlay, thirdOverlayProgress, shouldRenderThirdOverlay, isWideRhpFocused, superWideRHPRouteKeys, isWideRHPClosing} = + const {secondOverlayProgress, shouldRenderSecondaryOverlay, thirdOverlayProgress, shouldRenderThirdOverlay, isWideRHPFocused, superWideRHPRouteKeys, isWideRHPClosing} = useContext(WideRHPContext); const route = useRoute(); @@ -129,26 +130,26 @@ function createModalStackNavigator(screens: Scr /> ))} - {!isSmallScreenWidth && shouldRenderSecondaryOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT && !isFocused && !isWideRHPClosing && !shouldRenderThirdOverlay ? ( + {!isSmallScreenWidth && shouldRenderSecondaryOverlay && isWideRHPRouteName(route.name) && !isFocused && !isWideRHPClosing && !shouldRenderThirdOverlay ? ( // This overlay is necessary to cover the gap under the narrow format RHP screen ) : null} - {!isSmallScreenWidth && shouldRenderSecondaryOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT && !!isWideRhpFocused && !isFocused ? ( + {!isSmallScreenWidth && shouldRenderSecondaryOverlay && isSuperWideRHPRouteName(route.name) && !!isWideRHPFocused && !isFocused ? ( ) : null} - {!isSmallScreenWidth && shouldRenderSecondaryOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT && !isWideRhpFocused && !isFocused ? ( + {!isSmallScreenWidth && shouldRenderSecondaryOverlay && isSuperWideRHPRouteName(route.name) && !isWideRHPFocused && !isFocused ? ( 0 ? modalStackOverlaySuperWideRHPWidth : receiptPaneRHPWidth} /> ) : null} - {!isSmallScreenWidth && shouldRenderThirdOverlay && route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT ? ( + {!isSmallScreenWidth && shouldRenderThirdOverlay && isWideRHPRouteName(route.name) ? ( require('../../../../pages/ScheduleCall/ScheduleCallConfirmationPage').default, }); +const ExpenseReportModalStackNavigator = createModalStackNavigator({ + [SCREENS.EXPENSE_REPORT_RHP]: () => require('../../../../pages/Search/SearchMoneyRequestReportPage').default, +}); + export { AddPersonalBankAccountModalStackNavigator, AddUnreportedExpenseModalStackNavigator, @@ -955,6 +960,7 @@ export { DomainCardModalStackNavigator, EditRequestStackNavigator, EnablePaymentsStackNavigator, + ExpenseReportModalStackNavigator, ExpensifyCardModalStackNavigator, FlagCommentStackNavigator, MergeTransactionStackNavigator, diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index 21e840527813..ecba263b7b7a 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -36,7 +36,7 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { const {shouldUseNarrowLayout, isSmallScreenWidth} = useResponsiveLayout(); const isExecutingRef = useRef(false); const screenOptions = useRHPScreenOptions(); - const {expandedRHPProgress, shouldRenderSecondaryOverlay, secondOverlayProgress, isWideRhpFocused, shouldRenderThirdOverlay, thirdOverlayProgress, isWideRHPClosing} = + const {expandedRHPProgress, shouldRenderSecondaryOverlay, secondOverlayProgress, isWideRHPFocused, shouldRenderThirdOverlay, thirdOverlayProgress, isWideRHPClosing} = useContext(WideRHPContext); const {windowWidth} = useWindowDimensions(); const modalCardStyleInterpolator = useModalCardStyleInterpolator(); @@ -87,7 +87,7 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { isExecutingRef.current = false; }, CONST.ANIMATED_TRANSITION); }, [navigation]); - console.log('isWideRHPFocused', {isWideRHPClosing, isWideRhpFocused}); + return ( @@ -298,18 +298,22 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { name={SCREENS.RIGHT_MODAL.SCHEDULE_CALL} component={ModalStackNavigators.ScheduleCallModalStackNavigator} /> + {/* The second overlay is here to cover the wide rhp screen underneath */} {/* It has a gap on the right to make the last rhp route (narrow) visible and pressable */} - {shouldRenderSecondaryOverlay && !shouldUseNarrowLayout && !isWideRhpFocused && !isWideRHPClosing && ( + {shouldRenderSecondaryOverlay && !shouldUseNarrowLayout && !isWideRHPFocused && !isWideRHPClosing && ( Navigation.closeRHPFlow()} /> )} - {shouldRenderSecondaryOverlay && !shouldUseNarrowLayout && !!isWideRhpFocused && ( + {shouldRenderSecondaryOverlay && !shouldUseNarrowLayout && !!isWideRHPFocused && ( ['config'] = { [SCREENS.REPORT_CHANGE_APPROVER.ADD_APPROVER]: ROUTES.REPORT_CHANGE_APPROVER_ADD_APPROVER.route, }, }, + [SCREENS.RIGHT_MODAL.EXPENSE_REPORT]: { + screens: { + [SCREENS.EXPENSE_REPORT_RHP]: ROUTES.EXPENSE_REPORT_RHP.route, + }, + }, }, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 664a7d716dcd..d1a252e599fc 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -2093,6 +2093,7 @@ type RightModalNavigatorParamList = { [SCREENS.RIGHT_MODAL.SCHEDULE_CALL]: NavigatorScreenParams; [SCREENS.RIGHT_MODAL.REPORT_CHANGE_APPROVER]: NavigatorScreenParams; [SCREENS.RIGHT_MODAL.MERGE_TRANSACTION]: NavigatorScreenParams; + [SCREENS.RIGHT_MODAL.EXPENSE_REPORT]: NavigatorScreenParams; }; type TravelNavigatorParamList = { @@ -2694,6 +2695,14 @@ type TestToolsModalModalNavigatorParamList = { }; }; +type ExpenseReportNavigatorParamList = { + [SCREENS.EXPENSE_REPORT_RHP]: { + reportID: string; + // eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md + backTo?: Routes; + }; +}; + type RootNavigatorParamList = PublicScreensParamList & AuthScreensParamList & SearchFullscreenNavigatorParamList; type OnboardingFlowName = keyof OnboardingModalNavigatorParamList; @@ -2799,4 +2808,5 @@ export type { MergeTransactionNavigatorParamList, AttachmentModalScreensParamList, SearchMoneyRequestReportParamList, + ExpenseReportNavigatorParamList, }; diff --git a/src/pages/Search/SearchMoneyRequestReportPage.tsx b/src/pages/Search/SearchMoneyRequestReportPage.tsx index 7403b0b7c706..b5be92b65411 100644 --- a/src/pages/Search/SearchMoneyRequestReportPage.tsx +++ b/src/pages/Search/SearchMoneyRequestReportPage.tsx @@ -19,7 +19,7 @@ import useTransactionsAndViolationsForReport from '@hooks/useTransactionsAndViol import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID'; import {getAllNonDeletedTransactions} from '@libs/MoneyRequestReportUtils'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; -import type {SearchReportParamList} from '@libs/Navigation/types'; +import type {ExpenseReportNavigatorParamList, SearchMoneyRequestReportParamList} from '@libs/Navigation/types'; import {getFilteredReportActionsForReportView, getIOUActionForTransactionID, getOneTransactionThreadReportID} from '@libs/ReportActionsUtils'; import {isValidReportIDFromPath} from '@libs/ReportUtils'; import Navigation from '@navigation/Navigation'; @@ -33,7 +33,9 @@ import type SCREENS from '@src/SCREENS'; import type {Policy} from '@src/types/onyx'; import {getEmptyObject} from '@src/types/utils/EmptyObject'; -type SearchMoneyRequestPageProps = PlatformStackScreenProps; +type SearchMoneyRequestPageProps = + | PlatformStackScreenProps + | PlatformStackScreenProps; const defaultReportMetadata = { isLoadingInitialReportActions: true, From eb6c8ed070ab0b6dbd28d74551716f248aadeeac Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Fri, 14 Nov 2025 14:15:36 +0100 Subject: [PATCH 22/64] Run prettier --- src/components/WideRHPContextProvider/types.ts | 2 +- src/libs/Navigation/linkingConfig/config.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/WideRHPContextProvider/types.ts b/src/components/WideRHPContextProvider/types.ts index de90dcc42c23..6ce0cbe17df8 100644 --- a/src/components/WideRHPContextProvider/types.ts +++ b/src/components/WideRHPContextProvider/types.ts @@ -49,7 +49,7 @@ type WideRHPContextType = { isWideRHPClosing: boolean; // Mark that wide rhp is being closed - setIsWideRHPClosing: (isClosing: boolean) => void + setIsWideRHPClosing: (isClosing: boolean) => void; }; // eslint-disable-next-line import/prefer-default-export diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 32a7ba2d6bad..6ee1a8f51c8f 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -1754,7 +1754,7 @@ const config: LinkingOptions['config'] = { [SCREENS.RIGHT_MODAL.EXPENSE_REPORT]: { screens: { [SCREENS.EXPENSE_REPORT_RHP]: ROUTES.EXPENSE_REPORT_RHP.route, - } + }, }, [SCREENS.RIGHT_MODAL.DOMAIN]: { screens: { From efa43f029e47fe21b62693dcd11cc2966de5140d Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Fri, 14 Nov 2025 14:52:53 +0100 Subject: [PATCH 23/64] added wrhp back button fix and fixed styles on super wide rhp --- .../MoneyRequestReportTransactionItem.tsx | 6 ++++-- src/components/WideRHPContextProvider/index.tsx | 6 ++++++ src/components/WideRHPContextProvider/types.ts | 3 +++ src/pages/home/ReportScreen.tsx | 4 +++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionItem.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionItem.tsx index f4a3a38847a9..6474753cb07f 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionItem.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionItem.tsx @@ -1,4 +1,4 @@ -import React, {useEffect, useMemo, useRef} from 'react'; +import React, {useContext, useEffect, useMemo, useRef} from 'react'; import type {View} from 'react-native'; import {getButtonRole} from '@components/Button/utils'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; @@ -6,6 +6,7 @@ import {PressableWithFeedback} from '@components/Pressable'; import type {SearchColumnType, TableColumnSize} from '@components/Search/types'; import {getExpenseHeaders} from '@components/SelectionListWithSections/SearchTableHeader'; import TransactionItemRow from '@components/TransactionItemRow'; +import {WideRHPContext} from '@components/WideRHPContextProvider'; import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle'; import useLocalize from '@hooks/useLocalize'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; @@ -90,6 +91,7 @@ function MoneyRequestReportTransactionItem({ const theme = useTheme(); const isPendingDelete = isTransactionPendingDelete(transaction); const pendingAction = getTransactionPendingAction(transaction); + const {isSuperWideRHPFocused} = useContext(WideRHPContext); const viewRef = useRef(null); @@ -154,7 +156,7 @@ function MoneyRequestReportTransactionItem({ columns={columns} areAllOptionalColumnsHidden={areAllOptionalColumnsHidden} isDisabled={isPendingDelete} - style={[styles.p3, isLargeScreenWidth && styles.pr0]} + style={[styles.p3, isLargeScreenWidth && !isSuperWideRHPFocused && styles.pr0]} onButtonPress={() => { handleOnPress(transaction.transactionID); }} diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index c00356bd4ec8..73138ee28214 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -173,6 +173,10 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { return !!focusedRouteKey && wideRHPRouteKeys.includes(focusedRouteKey); }, [focusedRouteKey, wideRHPRouteKeys]); + const isSuperWideRHPFocused = useMemo(() => { + return !!focusedRouteKey && superWideRHPRouteKeys.includes(focusedRouteKey); + }, [focusedRouteKey, superWideRHPRouteKeys]); + /** * Determines whether the secondary overlay should be displayed. * Shows second overlay when RHP is open and there is a wide RHP route open but there is another regular route on the top. @@ -452,6 +456,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { markReportIDAsExpense, isReportIDMarkedAsExpense, isWideRHPFocused, + isSuperWideRHPFocused, isWideRHPClosing, setIsWideRHPClosing, }), @@ -467,6 +472,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { markReportIDAsExpense, isReportIDMarkedAsExpense, isWideRHPFocused, + isSuperWideRHPFocused, isWideRHPClosing, setIsWideRHPClosing, ], diff --git a/src/components/WideRHPContextProvider/types.ts b/src/components/WideRHPContextProvider/types.ts index 6ce0cbe17df8..5d430062a01b 100644 --- a/src/components/WideRHPContextProvider/types.ts +++ b/src/components/WideRHPContextProvider/types.ts @@ -45,6 +45,9 @@ type WideRHPContextType = { // Whether the currently focused route is inside the wide RHP set isWideRHPFocused: boolean; + // Whether the currently focused route is inside the super wide RHP set + isSuperWideRHPFocused: boolean; + // Whether the wide rhp modal is closing isWideRHPClosing: boolean; diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 04395d489507..ed0389b01078 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -412,7 +412,9 @@ function ReportScreen({route, navigation}: ReportScreenProps) { report={report} policy={policy} parentReportAction={parentReportAction} - onBackButtonPress={onBackButtonPress} + onBackButtonPress={() => { + onBackButtonPress(true); + }} /> ); } From 2f8ec7c262c887d8a5524aa1fa410bd9d9e1aab1 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Fri, 14 Nov 2025 15:10:48 +0100 Subject: [PATCH 24/64] Fix displaying secondary overlay --- src/components/WideRHPContextProvider/index.tsx | 11 ++++++++--- .../AppNavigator/ModalStackNavigators/index.tsx | 9 ++++++++- src/libs/Navigation/helpers/isWideRHPRouteName.ts | 11 ----------- 3 files changed, 16 insertions(+), 15 deletions(-) delete mode 100644 src/libs/Navigation/helpers/isWideRHPRouteName.ts diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 73138ee28214..bb30b29d19b7 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -9,7 +9,6 @@ import type {OnyxCollection} from 'react-native-onyx'; import useOnyx from '@hooks/useOnyx'; import useRootNavigationState from '@hooks/useRootNavigationState'; import {isFullScreenName} from '@libs/Navigation/helpers/isNavigatorName'; -import {isSuperWideRHPRouteName} from '@libs/Navigation/helpers/isWideRHPRouteName'; import navigationRef from '@libs/Navigation/navigationRef'; import type {NavigationRoute, RootNavigatorParamList} from '@libs/Navigation/types'; import variables from '@styles/variables'; @@ -30,6 +29,10 @@ const thirdOverlayProgress = new Animated.Value(0); const singleRHPWidth = variables.sideBarWidth; const wideRHPMaxWidth = variables.receiptPaneRHPMaxWidth + singleRHPWidth; +function isSuperWideRHPRouteName(routeName: string) { + return routeName === SCREENS.SEARCH.MONEY_REQUEST_REPORT || routeName === SCREENS.EXPENSE_REPORT_RHP; +} + /** * Utility function that extracts all unique navigation keys from a React Navigation state. * Recursively traverses the navigation state tree and collects all route keys. @@ -198,8 +201,10 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { return false; } + const isFocusedRouteSuperWide = isSuperWideRHPRouteName(focusedRoute.name); + // This screen is always first in RHP, so secondary overlay is not displayed in this case. - if (isSuperWideRHPRouteName(focusedRoute.name)) { + if (isFocusedRouteSuperWide) { return false; } @@ -207,7 +212,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { return false; } - if (currentSuperWideRHPRouteKeys.length > 0 && !currentSuperWideRHPRouteKeys.includes(focusedRoute.key) && isRHPLastRootRoute && !isSuperWideRHPRouteName(focusedRoute.name)) { + if (currentSuperWideRHPRouteKeys.length > 0 && !currentSuperWideRHPRouteKeys.includes(focusedRoute.key) && isRHPLastRootRoute && !isFocusedRouteSuperWide) { return true; } diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 7a81029e5112..c3448ffe89b7 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -6,7 +6,6 @@ import {modalStackOverlaySuperWideRHPWidth, modalStackOverlayWideRHPWidth, recei import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import Overlay from '@libs/Navigation/AppNavigator/Navigators/Overlay'; -import {isSuperWideRHPRouteName, isWideRHPRouteName} from '@libs/Navigation/helpers/isWideRHPRouteName'; import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; import Animations from '@libs/Navigation/PlatformStackNavigation/navigationOptions/animation'; import type {PlatformStackNavigationOptions} from '@libs/Navigation/PlatformStackNavigation/types'; @@ -87,6 +86,14 @@ const OPTIONS_PER_SCREEN: Partial }, }; +function isSuperWideRHPRouteName(routeName: string) { + return routeName === SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT || routeName === SCREENS.RIGHT_MODAL.EXPENSE_REPORT; +} + +function isWideRHPRouteName(routeName: string) { + return routeName === SCREENS.RIGHT_MODAL.SEARCH_REPORT; +} + /** * Create a modal stack navigator with an array of sub-screens. * diff --git a/src/libs/Navigation/helpers/isWideRHPRouteName.ts b/src/libs/Navigation/helpers/isWideRHPRouteName.ts deleted file mode 100644 index 46c3a8a54736..000000000000 --- a/src/libs/Navigation/helpers/isWideRHPRouteName.ts +++ /dev/null @@ -1,11 +0,0 @@ -import SCREENS from '@src/SCREENS'; - -function isSuperWideRHPRouteName(routeName: string) { - return routeName === SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT || routeName === SCREENS.RIGHT_MODAL.EXPENSE_REPORT; -} - -function isWideRHPRouteName(routeName: string) { - return routeName === SCREENS.RIGHT_MODAL.SEARCH_REPORT; -} - -export {isSuperWideRHPRouteName, isWideRHPRouteName}; From fbb995cd63911cc5b80ebfe0527cccaf6b0cef68 Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Fri, 14 Nov 2025 15:28:21 +0100 Subject: [PATCH 25/64] removed unnecessary function --- .../MoneyRequestReportTransactionItem.tsx | 4 ++-- src/components/WideRHPContextProvider/index.tsx | 6 ------ src/components/WideRHPContextProvider/types.ts | 3 --- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionItem.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionItem.tsx index 6474753cb07f..2cb99cb3e834 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionItem.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionItem.tsx @@ -91,7 +91,7 @@ function MoneyRequestReportTransactionItem({ const theme = useTheme(); const isPendingDelete = isTransactionPendingDelete(transaction); const pendingAction = getTransactionPendingAction(transaction); - const {isSuperWideRHPFocused} = useContext(WideRHPContext); + const {superWideRHPRouteKeys} = useContext(WideRHPContext); const viewRef = useRef(null); @@ -156,7 +156,7 @@ function MoneyRequestReportTransactionItem({ columns={columns} areAllOptionalColumnsHidden={areAllOptionalColumnsHidden} isDisabled={isPendingDelete} - style={[styles.p3, isLargeScreenWidth && !isSuperWideRHPFocused && styles.pr0]} + style={[styles.p3, isLargeScreenWidth && !superWideRHPRouteKeys.length && styles.pr0]} onButtonPress={() => { handleOnPress(transaction.transactionID); }} diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index bb30b29d19b7..d432dff57aaf 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -176,10 +176,6 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { return !!focusedRouteKey && wideRHPRouteKeys.includes(focusedRouteKey); }, [focusedRouteKey, wideRHPRouteKeys]); - const isSuperWideRHPFocused = useMemo(() => { - return !!focusedRouteKey && superWideRHPRouteKeys.includes(focusedRouteKey); - }, [focusedRouteKey, superWideRHPRouteKeys]); - /** * Determines whether the secondary overlay should be displayed. * Shows second overlay when RHP is open and there is a wide RHP route open but there is another regular route on the top. @@ -461,7 +457,6 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { markReportIDAsExpense, isReportIDMarkedAsExpense, isWideRHPFocused, - isSuperWideRHPFocused, isWideRHPClosing, setIsWideRHPClosing, }), @@ -477,7 +472,6 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { markReportIDAsExpense, isReportIDMarkedAsExpense, isWideRHPFocused, - isSuperWideRHPFocused, isWideRHPClosing, setIsWideRHPClosing, ], diff --git a/src/components/WideRHPContextProvider/types.ts b/src/components/WideRHPContextProvider/types.ts index 5d430062a01b..6ce0cbe17df8 100644 --- a/src/components/WideRHPContextProvider/types.ts +++ b/src/components/WideRHPContextProvider/types.ts @@ -45,9 +45,6 @@ type WideRHPContextType = { // Whether the currently focused route is inside the wide RHP set isWideRHPFocused: boolean; - // Whether the currently focused route is inside the super wide RHP set - isSuperWideRHPFocused: boolean; - // Whether the wide rhp modal is closing isWideRHPClosing: boolean; From 10114db0cf020f7f9ac8957d852827f6991f8e49 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Fri, 14 Nov 2025 15:38:08 +0100 Subject: [PATCH 26/64] Add comments --- src/components/WideRHPContextProvider/types.ts | 4 ++-- .../AppNavigator/Navigators/Overlay/BaseOverlay.tsx | 3 +++ .../AppNavigator/Navigators/RightModalNavigator.tsx | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/WideRHPContextProvider/types.ts b/src/components/WideRHPContextProvider/types.ts index 6ce0cbe17df8..a879273f7e5a 100644 --- a/src/components/WideRHPContextProvider/types.ts +++ b/src/components/WideRHPContextProvider/types.ts @@ -15,13 +15,13 @@ type WideRHPContextType = { // Progress of the secondary overlay, the one covering wider RHP screen secondOverlayProgress: Animated.Value; - // Progress of the secondary overlay, the one covering wider RHP screen + // Progress of the tertiary overlay, the one covering wider RHP screen thirdOverlayProgress: Animated.Value; // If the secondary overlay should be rendered. This value takes into account the delay of closing transition. shouldRenderSecondaryOverlay: boolean; - // If the secondary overlay should be rendered. This value takes into account the delay of closing transition. + // If the tertiary overlay should be rendered. This value takes into account the delay of closing transition. shouldRenderThirdOverlay: boolean; // Show given route as in wide format diff --git a/src/libs/Navigation/AppNavigator/Navigators/Overlay/BaseOverlay.tsx b/src/libs/Navigation/AppNavigator/Navigators/Overlay/BaseOverlay.tsx index 073804cb8669..aeec2f1cb64a 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/Overlay/BaseOverlay.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/Overlay/BaseOverlay.tsx @@ -16,11 +16,14 @@ type BaseOverlayProps = { /* Override the progress from useCardAnimation. Necessary for the secondary overlay */ progress?: OverlayStylesParams; + /* Overlay position from the left edge of the container */ positionLeftValue?: number | Animated.Value; + /* Overlay position from the right edge of the container */ positionRightValue?: number | Animated.Value; }; +// The default value of postionLeftValue is equal to -2 * variables.sideBarWidth, because we need to stretch the overlay to cover the sidebar and the translate animation distance. function BaseOverlay({onPress, progress, positionLeftValue = -2 * variables.sideBarWidth, positionRightValue = 0}: BaseOverlayProps) { const styles = useThemeStyles(); const {current} = useCardAnimation(); diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index efa8746e450c..4d880df4056f 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -52,7 +52,7 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { right: 0, position: 'absolute', overflow: 'hidden', - width: shouldUseNarrowLayout ? '100%' : (animatedWidth as unknown as number), + width: shouldUseNarrowLayout ? '100%' : animatedWidth, } as const; }, [animatedWidth, shouldUseNarrowLayout]); From eb17e49e3bfab2c657248579e7699141b9214e1f Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Fri, 14 Nov 2025 15:56:50 +0100 Subject: [PATCH 27/64] Fix styles --- .../useModalStackScreenOptions.ts | 8 +++----- src/styles/index.ts | 13 ++++++------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/useModalStackScreenOptions.ts b/src/libs/Navigation/AppNavigator/ModalStackNavigators/useModalStackScreenOptions.ts index 4a80e00f7f76..c87c8f79c2e5 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/useModalStackScreenOptions.ts +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/useModalStackScreenOptions.ts @@ -4,7 +4,6 @@ import {useCallback, useContext} from 'react'; import {WideRHPContext} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; -import useWindowDimensions from '@hooks/useWindowDimensions'; import enhanceCardStyleInterpolator from '@libs/Navigation/AppNavigator/enhanceCardStyleInterpolator'; import hideKeyboardOnSwipe from '@libs/Navigation/AppNavigator/hideKeyboardOnSwipe'; import type {PlatformStackNavigationOptions, PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types'; @@ -18,7 +17,6 @@ function useModalStackScreenOptions() { // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth const {isSmallScreenWidth} = useResponsiveLayout(); const {wideRHPRouteKeys, superWideRHPRouteKeys} = useContext(WideRHPContext); - const {windowWidth} = useWindowDimensions(); return useCallback<({route}: {route: PlatformStackRouteProp}) => PlatformStackNavigationOptions>( ({route}) => { @@ -26,13 +24,13 @@ function useModalStackScreenOptions() { if (superWideRHPRouteKeys.includes(route.key) && !isSmallScreenWidth) { cardStyleInterpolator = enhanceCardStyleInterpolator(CardStyleInterpolators.forHorizontalIOS, { - cardStyle: styles.superWideRHPExtendedCardInterpolatorStyles(windowWidth), + cardStyle: styles.superWideRHPExtendedCardInterpolatorStyles, }); } else if (wideRHPRouteKeys.includes(route.key) && !isSmallScreenWidth) { // We need to use interpolator styles instead of regular card styles so we can use animated value for width. // It is necessary to have responsive width of the wide RHP for range 800px to 840px. cardStyleInterpolator = enhanceCardStyleInterpolator(CardStyleInterpolators.forHorizontalIOS, { - cardStyle: styles.wideRHPExtendedCardInterpolatorStyles(windowWidth), + cardStyle: styles.wideRHPExtendedCardInterpolatorStyles, }); } else { cardStyleInterpolator = CardStyleInterpolators.forHorizontalIOS; @@ -51,7 +49,7 @@ function useModalStackScreenOptions() { }, }; }, - [isSmallScreenWidth, styles, superWideRHPRouteKeys, wideRHPRouteKeys, windowWidth], + [isSmallScreenWidth, styles, superWideRHPRouteKeys, wideRHPRouteKeys], ); } diff --git a/src/styles/index.ts b/src/styles/index.ts index 1dd1a24f6b97..8a018125afc5 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -3,7 +3,6 @@ /* eslint-disable @typescript-eslint/naming-convention */ import type {LineLayerStyleProps} from '@rnmapbox/maps/src/utils/MapboxStyles'; import lodashClamp from 'lodash/clamp'; -import type {RefObject} from 'react'; import type {LineLayer} from 'react-map-gl'; import type {ImageStyle, TextStyle, ViewStyle} from 'react-native'; // eslint-disable-next-line no-restricted-imports @@ -15,7 +14,7 @@ import type {MixedStyleDeclaration, MixedStyleRecord} from 'react-native-render- import type {ValueOf} from 'type-fest'; import type DotLottieAnimation from '@components/LottieAnimations/types'; import {ACTIVE_LABEL_SCALE} from '@components/TextInput/styleConst'; -import {calculateReceiptPaneRHPWidth, receiptPaneRHPWidth, superWideRHPWidth} from '@components/WideRHPContextProvider'; +import {receiptPaneRHPWidth, superWideRHPWidth, wideRHPWidth} from '@components/WideRHPContextProvider'; import {getBrowser, isMobile, isMobileSafari, isSafari} from '@libs/Browser'; import getPlatform from '@libs/getPlatform'; import CONST from '@src/CONST'; @@ -5351,19 +5350,19 @@ const staticStyles = (theme: ThemeColors) => backgroundColor: colors.green800, }, - wideRHPExtendedCardInterpolatorStyles: (windowWidth: number) => ({ + wideRHPExtendedCardInterpolatorStyles: { position: Platform.OS === 'web' ? 'fixed' : 'absolute', height: '100%', right: 0, - width: Animated.add(variables.sideBarWidth, calculateReceiptPaneRHPWidth(windowWidth)), - }), + width: wideRHPWidth, + }, - superWideRHPExtendedCardInterpolatorStyles: (windowWidth: number) => ({ + superWideRHPExtendedCardInterpolatorStyles: { position: Platform.OS === 'web' ? 'fixed' : 'absolute', height: '100%', right: 0, width: superWideRHPWidth, - }), + }, flexibleHeight: { height: 'auto', From 1c1fdaa543d74583604a91e344ead36911ff0f2b Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Fri, 14 Nov 2025 16:07:58 +0100 Subject: [PATCH 28/64] Fix spell check --- .../Navigation/AppNavigator/Navigators/Overlay/BaseOverlay.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Navigation/AppNavigator/Navigators/Overlay/BaseOverlay.tsx b/src/libs/Navigation/AppNavigator/Navigators/Overlay/BaseOverlay.tsx index aeec2f1cb64a..5356f59e620b 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/Overlay/BaseOverlay.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/Overlay/BaseOverlay.tsx @@ -23,7 +23,7 @@ type BaseOverlayProps = { positionRightValue?: number | Animated.Value; }; -// The default value of postionLeftValue is equal to -2 * variables.sideBarWidth, because we need to stretch the overlay to cover the sidebar and the translate animation distance. +// The default value of positionLeftValue is equal to -2 * variables.sideBarWidth, because we need to stretch the overlay to cover the sidebar and the translate animation distance. function BaseOverlay({onPress, progress, positionLeftValue = -2 * variables.sideBarWidth, positionRightValue = 0}: BaseOverlayProps) { const styles = useThemeStyles(); const {current} = useCardAnimation(); From fbee6dbc456f3f05fff173bd3be500cef142a281 Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Fri, 14 Nov 2025 16:14:29 +0100 Subject: [PATCH 29/64] fixed some types --- src/components/MoneyReportHeader.tsx | 4 ++-- src/components/WideRHPContextProvider/index.tsx | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 933360570451..fcd4983821b8 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -42,7 +42,7 @@ import Log from '@libs/Log'; import {getThreadReportIDsForTransactions, getTotalAmountForIOUReportPreviewButton} from '@libs/MoneyRequestReportUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types'; -import type {ReportsSplitNavigatorParamList, SearchReportParamList} from '@libs/Navigation/types'; +import type {ReportsSplitNavigatorParamList, SearchMoneyRequestReportParamList, SearchReportParamList} from '@libs/Navigation/types'; import {buildOptimisticNextStepForPreventSelfApprovalsEnabled, buildOptimisticNextStepForStrictPolicyRuleViolations} from '@libs/NextStepUtils'; import type {KYCFlowEvent, TriggerKYCFlow} from '@libs/PaymentUtils'; import {selectPaymentType} from '@libs/PaymentUtils'; @@ -185,7 +185,7 @@ function MoneyReportHeader({ const shouldDisplayNarrowVersion = shouldUseNarrowLayout || isMediumScreenWidth; const route = useRoute< | PlatformStackRouteProp - | PlatformStackRouteProp + | PlatformStackRouteProp | PlatformStackRouteProp >(); const {login: currentUserLogin, accountID, email} = useCurrentUserPersonalDetails(); diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index d432dff57aaf..44ffd272cc3a 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -10,7 +10,7 @@ import useOnyx from '@hooks/useOnyx'; import useRootNavigationState from '@hooks/useRootNavigationState'; import {isFullScreenName} from '@libs/Navigation/helpers/isNavigatorName'; import navigationRef from '@libs/Navigation/navigationRef'; -import type {NavigationRoute, RootNavigatorParamList} from '@libs/Navigation/types'; +import type {NavigationRoute} from '@libs/Navigation/types'; import variables from '@styles/variables'; import CONST from '@src/CONST'; import NAVIGATORS from '@src/NAVIGATORS'; @@ -138,7 +138,7 @@ function getCurrentWideRHPKeys(allWideRHPKeys: string[], lastVisibleRHPRouteKey: return currentKeys; } -function getLastVisibleRHPRouteKey(state: NavigationState) { +function getLastVisibleRHPRouteKey(state: NavigationState | undefined) { // Safe handling when navigation is not yet initialized if (!state) { return undefined; @@ -163,7 +163,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const [shouldRenderThirdOverlay, setShouldRenderThirdOverlay] = useState(false); const [expenseReportIDs, setExpenseReportIDs] = useState>(new Set()); const [isWideRHPClosing, setIsWideRHPClosing] = useState(false); - const focusedRouteKey = useRootNavigationState((state) => findFocusedRoute(state))?.key; + const focusedRouteKey = useRootNavigationState((state) => (state ? findFocusedRoute(state)?.key : undefined)); const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {selector: expenseReportSelector, canBeMissing: true}); // Return undefined if RHP is not the last route From df9b81d79c5ae95f8fc1751c4728b52e39e29e2b Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Fri, 14 Nov 2025 16:32:37 +0100 Subject: [PATCH 30/64] fixed some eslint errors and types --- .../MoneyRequestReportView.tsx | 1 + .../Navigators/RightModalNavigator.tsx | 25 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx index b06e5e3396dc..2974a4643c2b 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx @@ -89,6 +89,7 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe const styles = useThemeStyles(); const {isOffline} = useNetwork(); + // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth const {isSmallScreenWidth} = useResponsiveLayout(); const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: false}); diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index 4d880df4056f..adddfd0493be 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -33,6 +33,7 @@ const singleRHPWidth = variables.sideBarWidth; const getWideRHPWidth = (windowWidth: number) => variables.sideBarWidth + calculateReceiptPaneRHPWidth(windowWidth); function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { + // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth const {shouldUseNarrowLayout, isSmallScreenWidth} = useResponsiveLayout(); const isExecutingRef = useRef(false); const screenOptions = useRHPScreenOptions(); @@ -256,18 +257,20 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { component={ModalStackNavigators.SearchReportModalStackNavigator} options={{ presentation: Presentation.TRANSPARENT_MODAL, - cardStyleInterpolator: (props: StackCardInterpolationProps) => - // Add 1 to change range from [0, 1] to [1, 2] - // Don't use outputMultiplier for the narrow layout - modalCardStyleInterpolator({ - props, - shouldAnimateSidePanel: true, + web: { + cardStyleInterpolator: (props: StackCardInterpolationProps) => + // Add 1 to change range from [0, 1] to [1, 2] + // Don't use outputMultiplier for the narrow layout + modalCardStyleInterpolator({ + props, + shouldAnimateSidePanel: true, - // Adjust output range to match the wide RHP size - outputRangeMultiplier: isSmallScreenWidth - ? undefined - : Animated.add(Animated.multiply(innerRHPProgress, variables.receiptPaneRHPMaxWidth / variables.sideBarWidth), 1), - }), + // Adjust output range to match the wide RHP size + outputRangeMultiplier: isSmallScreenWidth + ? undefined + : Animated.add(Animated.multiply(innerRHPProgress, variables.receiptPaneRHPMaxWidth / variables.sideBarWidth), 1), + }), + }, }} /> Date: Fri, 14 Nov 2025 16:55:57 +0100 Subject: [PATCH 31/64] Fix ts --- src/components/ParentNavigationSubtitle.tsx | 4 ++-- src/components/WideRHPContextProvider/default.ts | 6 ++++++ tests/utils/TestNavigationContainer.tsx | 4 ---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/ParentNavigationSubtitle.tsx b/src/components/ParentNavigationSubtitle.tsx index 2a51ec572dc5..5892e9c11d30 100644 --- a/src/components/ParentNavigationSubtitle.tsx +++ b/src/components/ParentNavigationSubtitle.tsx @@ -12,7 +12,7 @@ import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import {isFullScreenName} from '@libs/Navigation/helpers/isNavigatorName'; import Navigation from '@libs/Navigation/Navigation'; -import type {SearchFullscreenNavigatorParamList} from '@libs/Navigation/types'; +import type {SearchMoneyRequestReportParamList} from '@libs/Navigation/types'; import {getReportAction, shouldReportActionBeVisible} from '@libs/ReportActionsUtils'; import {canUserPerformWriteAction as canUserPerformWriteActionReportUtils} from '@libs/ReportUtils'; import CONST from '@src/CONST'; @@ -98,7 +98,7 @@ function ParentNavigationSubtitle({ if (currentFullScreenRoute?.name === NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR) { const lastRoute = currentFullScreenRoute?.state?.routes.at(-1); if (lastRoute?.name === SCREENS.SEARCH.MONEY_REQUEST_REPORT) { - const moneyRequestReportID = (lastRoute?.params as SearchFullscreenNavigatorParamList[typeof SCREENS.SEARCH.MONEY_REQUEST_REPORT])?.reportID; + const moneyRequestReportID = (lastRoute?.params as SearchMoneyRequestReportParamList[typeof SCREENS.SEARCH.MONEY_REQUEST_REPORT])?.reportID; // If the parent report is already displayed underneath RHP, simply dismiss the modal if (moneyRequestReportID === parentReportID) { Navigation.dismissModal(); diff --git a/src/components/WideRHPContextProvider/default.ts b/src/components/WideRHPContextProvider/default.ts index 02c3a2d69c49..d10588d9b0ce 100644 --- a/src/components/WideRHPContextProvider/default.ts +++ b/src/components/WideRHPContextProvider/default.ts @@ -14,6 +14,12 @@ const defaultWideRHPContextValue: WideRHPContextType = { markReportIDAsExpense: () => {}, isReportIDMarkedAsExpense: () => false, dismissToWideReport: () => {}, + isWideRHPClosing: false, + setIsWideRHPClosing: () => {}, + isWideRHPFocused: false, + shouldRenderThirdOverlay: false, + superWideRHPRouteKeys: [], + showSuperWideRHPVersion: () => {}, }; export default defaultWideRHPContextValue; diff --git a/tests/utils/TestNavigationContainer.tsx b/tests/utils/TestNavigationContainer.tsx index 0c3370f12de0..37476a42bd19 100644 --- a/tests/utils/TestNavigationContainer.tsx +++ b/tests/utils/TestNavigationContainer.tsx @@ -114,10 +114,6 @@ function TestSearchFullscreenNavigator() { name={SCREENS.SEARCH.ROOT} getComponent={getEmptyComponent()} /> - ); } From 521ae1a3ae3a87b0ffbec573c64f282e6f6b56aa Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Fri, 14 Nov 2025 17:02:26 +0100 Subject: [PATCH 32/64] Fix abs function types --- .../Navigation/AppNavigator/useRootNavigatorScreenOptions.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts b/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts index 33e06ab7eacd..fcc5c8a1934d 100644 --- a/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts +++ b/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts @@ -30,8 +30,7 @@ const commonScreenOptions: PlatformStackNavigationOptions = { }, }; -/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument */ -function abs(a: any) { +function abs(a: Animated.AnimatedSubtraction) { const b = Animated.multiply(a, -1); const clampedA = Animated.diffClamp(a, 0, Number.MAX_SAFE_INTEGER); const clampedB = Animated.diffClamp(b, 0, Number.MAX_SAFE_INTEGER); From dba4c2b70a6e554f750c3efdc95c634f3f72650b Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Fri, 14 Nov 2025 17:12:17 +0100 Subject: [PATCH 33/64] Fix missing default values in WideRHPContextProvider --- src/components/WideRHPContextProvider/default.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/WideRHPContextProvider/default.ts b/src/components/WideRHPContextProvider/default.ts index d10588d9b0ce..cc7bf6d48a87 100644 --- a/src/components/WideRHPContextProvider/default.ts +++ b/src/components/WideRHPContextProvider/default.ts @@ -20,6 +20,7 @@ const defaultWideRHPContextValue: WideRHPContextType = { shouldRenderThirdOverlay: false, superWideRHPRouteKeys: [], showSuperWideRHPVersion: () => {}, + thirdOverlayProgress: new Animated.Value(0), }; export default defaultWideRHPContextValue; From 8713c0662f8ef7128bfbe7d3d1a3c8e5d8e3a07d Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Mon, 17 Nov 2025 15:35:28 +0100 Subject: [PATCH 34/64] Add dismissToFirstRHP and dismissToSecondRHP methods --- .../WideRHPContextProvider/default.ts | 5 +- .../WideRHPContextProvider/index.tsx | 64 +++++++++++++++---- .../WideRHPContextProvider/types.ts | 9 ++- .../Navigation/AppNavigator/AuthScreens.tsx | 11 +++- .../ModalStackNavigators/index.tsx | 6 +- .../Navigators/RightModalNavigator.tsx | 22 +++++-- 6 files changed, 87 insertions(+), 30 deletions(-) diff --git a/src/components/WideRHPContextProvider/default.ts b/src/components/WideRHPContextProvider/default.ts index cc7bf6d48a87..cb8529ce0c9c 100644 --- a/src/components/WideRHPContextProvider/default.ts +++ b/src/components/WideRHPContextProvider/default.ts @@ -13,11 +13,12 @@ const defaultWideRHPContextValue: WideRHPContextType = { cleanWideRHPRouteKey: () => {}, markReportIDAsExpense: () => {}, isReportIDMarkedAsExpense: () => false, - dismissToWideReport: () => {}, + dismissToFirstRHP: () => {}, + dismissToSecondRHP: () => {}, isWideRHPClosing: false, setIsWideRHPClosing: () => {}, isWideRHPFocused: false, - shouldRenderThirdOverlay: false, + shouldRenderTertiaryOverlay: false, superWideRHPRouteKeys: [], showSuperWideRHPVersion: () => {}, thirdOverlayProgress: new Animated.Value(0), diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 44ffd272cc3a..9f0ebc6397d1 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -29,6 +29,13 @@ const thirdOverlayProgress = new Animated.Value(0); const singleRHPWidth = variables.sideBarWidth; const wideRHPMaxWidth = variables.receiptPaneRHPMaxWidth + singleRHPWidth; +const OVERLAY_TIMING_DURATION = 300; + +// This array includes wide and super wide right modals +const WIDE_RIGHT_MODALS = new Set([SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT, SCREENS.RIGHT_MODAL.EXPENSE_REPORT, SCREENS.RIGHT_MODAL.SEARCH_REPORT]); + +const SUPER_WIDE_RIGHT_MODALS = new Set([SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT, SCREENS.RIGHT_MODAL.EXPENSE_REPORT]); + function isSuperWideRHPRouteName(routeName: string) { return routeName === SCREENS.SEARCH.MONEY_REQUEST_REPORT || routeName === SCREENS.EXPENSE_REPORT_RHP; } @@ -160,7 +167,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const [allWideRHPRouteKeys, setAllWideRHPRouteKeys] = useState([]); const [allSuperWideRHPRouteKeys, setAllSuperWideRHPRouteKeys] = useState([]); const [shouldRenderSecondaryOverlay, setShouldRenderSecondaryOverlay] = useState(false); - const [shouldRenderThirdOverlay, setShouldRenderThirdOverlay] = useState(false); + const [shouldRenderTertiaryOverlay, setShouldRenderTertiaryOverlay] = useState(false); const [expenseReportIDs, setExpenseReportIDs] = useState>(new Set()); const [isWideRHPClosing, setIsWideRHPClosing] = useState(false); const focusedRouteKey = useRootNavigationState((state) => (state ? findFocusedRoute(state)?.key : undefined)); @@ -300,7 +307,38 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { /** * Dismiss top layer modal and go back to the wide RHP. */ - const dismissToWideReport = useCallback(() => { + const dismissToFirstRHP = useCallback(() => { + const rootState = navigationRef.getRootState(); + if (!rootState) { + return; + } + + const rhpState = rootState.routes.findLast((route) => route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR)?.state; + + if (!rhpState) { + return; + } + + let firstRHPIndex; + + // If Wide RHP is focused, we should dismiss to Super Wide RHP + if (isWideRHPFocused) { + firstRHPIndex = rhpState.routes.findLastIndex((route) => SUPER_WIDE_RIGHT_MODALS.has(route.name)); + } else { + firstRHPIndex = rhpState.routes.findLastIndex((route) => WIDE_RIGHT_MODALS.has(route.name)); + } + + const routesToPop = rhpState.routes.length - firstRHPIndex - 1; + + // In the current navigation structure, hardcoding popTo SCREENS.RIGHT_MODAL.SEARCH_REPORT works exactly as we want. + // It may change in the future and we may need to improve this function to handle more complex configurations. + navigationRef.dispatch({...StackActions.pop(routesToPop), target: rhpState.key}); + }, [isWideRHPFocused]); + + /** + * Dismiss top layer modal and go back to the wide RHP. + */ + const dismissToSecondRHP = useCallback(() => { const rootState = navigationRef.getRootState(); if (!rootState) { return; @@ -378,13 +416,13 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { setShouldRenderSecondaryOverlay(true); Animated.timing(secondOverlayProgress, { toValue: 1, - duration: 300, + duration: OVERLAY_TIMING_DURATION, useNativeDriver: false, }).start(); } else { Animated.timing(secondOverlayProgress, { toValue: 0, - duration: 300, + duration: OVERLAY_TIMING_DURATION, useNativeDriver: false, }).start(() => { setShouldRenderSecondaryOverlay(false); @@ -397,19 +435,19 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { */ useEffect(() => { if (shouldShowThirdOverlay) { - setShouldRenderThirdOverlay(true); + setShouldRenderTertiaryOverlay(true); Animated.timing(thirdOverlayProgress, { toValue: 1, - duration: 300, + duration: OVERLAY_TIMING_DURATION, useNativeDriver: false, }).start(); } else { Animated.timing(thirdOverlayProgress, { toValue: 0, - duration: 300, + duration: OVERLAY_TIMING_DURATION, useNativeDriver: false, }).start(() => { - setShouldRenderThirdOverlay(false); + setShouldRenderTertiaryOverlay(false); }); } }, [shouldShowThirdOverlay]); @@ -452,8 +490,9 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { secondOverlayProgress, thirdOverlayProgress, shouldRenderSecondaryOverlay, - shouldRenderThirdOverlay, - dismissToWideReport, + shouldRenderTertiaryOverlay, + dismissToFirstRHP, + dismissToSecondRHP, markReportIDAsExpense, isReportIDMarkedAsExpense, isWideRHPFocused, @@ -467,13 +506,14 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { showSuperWideRHPVersion, cleanWideRHPRouteKey, shouldRenderSecondaryOverlay, - shouldRenderThirdOverlay, - dismissToWideReport, + shouldRenderTertiaryOverlay, markReportIDAsExpense, isReportIDMarkedAsExpense, isWideRHPFocused, isWideRHPClosing, setIsWideRHPClosing, + dismissToFirstRHP, + dismissToSecondRHP, ], ); diff --git a/src/components/WideRHPContextProvider/types.ts b/src/components/WideRHPContextProvider/types.ts index a879273f7e5a..fca293bae0f8 100644 --- a/src/components/WideRHPContextProvider/types.ts +++ b/src/components/WideRHPContextProvider/types.ts @@ -22,7 +22,7 @@ type WideRHPContextType = { shouldRenderSecondaryOverlay: boolean; // If the tertiary overlay should be rendered. This value takes into account the delay of closing transition. - shouldRenderThirdOverlay: boolean; + shouldRenderTertiaryOverlay: boolean; // Show given route as in wide format showWideRHPVersion: (route: NavigationRoute) => void; @@ -39,8 +39,11 @@ type WideRHPContextType = { // Check if reportID is marked as expense isReportIDMarkedAsExpense: (reportID: string) => boolean; - // Navigate to the last element in wideRHPRouteKeys array - dismissToWideReport: () => void; + // Navigate to the first visible RHP + dismissToFirstRHP: () => void; + + // Navigate to the second visible RHP + dismissToSecondRHP: () => void; // Whether the currently focused route is inside the wide RHP set isWideRHPFocused: boolean; diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index a1b32d5f28d2..407ca33a47cc 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -154,7 +154,7 @@ function AuthScreens() { const {initialURL, isAuthenticatedAtStartup, setIsAuthenticatedAtStartup} = useContext(InitialURLContext); const modalCardStyleInterpolator = useModalCardStyleInterpolator(); const archivedReportsIdSet = useArchivedReportsIdSet(); - const {shouldRenderSecondaryOverlay, dismissToWideReport} = useContext(WideRHPContext); + const {shouldRenderSecondaryOverlay, shouldRenderTertiaryOverlay, dismissToFirstRHP, dismissToSecondRHP} = useContext(WideRHPContext); // State to track whether the delegator's authentication is completed before displaying data const [isDelegatorFromOldDotIsReady, setIsDelegatorFromOldDotIsReady] = useState(false); @@ -342,7 +342,12 @@ function AuthScreens() { } if (shouldRenderSecondaryOverlay) { - dismissToWideReport(); + dismissToFirstRHP(); + return; + } + + if (shouldRenderTertiaryOverlay) { + dismissToSecondRHP(); return; } @@ -354,7 +359,7 @@ function AuthScreens() { true, ); return () => unsubscribeEscapeKey(); - }, [dismissToWideReport, modal?.disableDismissOnEscape, modal?.willAlertModalBecomeVisible, shouldRenderSecondaryOverlay]); + }, [dismissToFirstRHP, dismissToSecondRHP, modal?.disableDismissOnEscape, modal?.willAlertModalBecomeVisible, shouldRenderSecondaryOverlay, shouldRenderTertiaryOverlay]); // Animation is disabled when navigating to the sidebar screen const getWorkspaceOrDomainSplitNavigatorOptions = ({route}: {route: RouteProp}) => { diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index c3448ffe89b7..b913da66780a 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -105,7 +105,7 @@ function createModalStackNavigator(screens: Scr function ModalStack() { const styles = useThemeStyles(); const screenOptions = useModalStackScreenOptions(); - const {secondOverlayProgress, shouldRenderSecondaryOverlay, thirdOverlayProgress, shouldRenderThirdOverlay, isWideRHPFocused, superWideRHPRouteKeys, isWideRHPClosing} = + const {secondOverlayProgress, shouldRenderSecondaryOverlay, thirdOverlayProgress, shouldRenderTertiaryOverlay, isWideRHPFocused, superWideRHPRouteKeys, isWideRHPClosing} = useContext(WideRHPContext); const route = useRoute(); @@ -140,7 +140,7 @@ function createModalStackNavigator(screens: Scr /> ))} - {!isSmallScreenWidth && shouldRenderSecondaryOverlay && isWideRHPRouteName(route.name) && !isFocused && !isWideRHPClosing && !shouldRenderThirdOverlay ? ( + {!isSmallScreenWidth && shouldRenderSecondaryOverlay && isWideRHPRouteName(route.name) && !isFocused && !isWideRHPClosing && !shouldRenderTertiaryOverlay ? ( // This overlay is necessary to cover the gap under the narrow format RHP screen (screens: Scr positionLeftValue={superWideRHPRouteKeys.length > 0 ? modalStackOverlaySuperWideRHPWidth : receiptPaneRHPWidth} /> ) : null} - {!isSmallScreenWidth && shouldRenderThirdOverlay && isWideRHPRouteName(route.name) ? ( + {!isSmallScreenWidth && shouldRenderTertiaryOverlay && isWideRHPRouteName(route.name) ? ( (false); const screenOptions = useRHPScreenOptions(); - const {expandedRHPProgress, shouldRenderSecondaryOverlay, secondOverlayProgress, isWideRHPFocused, shouldRenderThirdOverlay, thirdOverlayProgress, isWideRHPClosing} = - useContext(WideRHPContext); + const { + expandedRHPProgress, + shouldRenderSecondaryOverlay, + secondOverlayProgress, + isWideRHPFocused, + shouldRenderTertiaryOverlay, + thirdOverlayProgress, + isWideRHPClosing, + dismissToFirstRHP, + dismissToSecondRHP, + } = useContext(WideRHPContext); const {windowWidth} = useWindowDimensions(); const modalCardStyleInterpolator = useModalCardStyleInterpolator(); @@ -317,21 +325,21 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { Navigation.closeRHPFlow()} + onPress={dismissToFirstRHP} /> )} {shouldRenderSecondaryOverlay && !shouldUseNarrowLayout && !!isWideRHPFocused && ( Navigation.closeRHPFlow()} + onPress={dismissToFirstRHP} /> )} - {shouldRenderThirdOverlay && !shouldUseNarrowLayout && ( + {shouldRenderTertiaryOverlay && !shouldUseNarrowLayout && ( Navigation.closeRHPFlow()} + onPress={dismissToSecondRHP} /> )} From ce181b3181b1f9d9bad728af17a8ba00105a459a Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Mon, 17 Nov 2025 15:49:44 +0100 Subject: [PATCH 35/64] Refactor styles in RightModalNavigator --- src/components/WideRHPContextProvider/types.ts | 2 +- .../AppNavigator/Navigators/RightModalNavigator.tsx | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/WideRHPContextProvider/types.ts b/src/components/WideRHPContextProvider/types.ts index fca293bae0f8..dfbbed000999 100644 --- a/src/components/WideRHPContextProvider/types.ts +++ b/src/components/WideRHPContextProvider/types.ts @@ -39,7 +39,7 @@ type WideRHPContextType = { // Check if reportID is marked as expense isReportIDMarkedAsExpense: (reportID: string) => boolean; - // Navigate to the first visible RHP + // Navigate to the first visible RHP dismissToFirstRHP: () => void; // Navigate to the second visible RHP diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index 6f24a3038bbe..7ce605a37992 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -6,6 +6,7 @@ import {Animated, InteractionManager} from 'react-native'; import NoDropZone from '@components/DragAndDrop/NoDropZone'; import {calculateReceiptPaneRHPWidth, calculateSuperWideRHPWidth, innerRHPProgress, WideRHPContext, wideRHPWidth} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; +import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import {abandonReviewDuplicateTransactions} from '@libs/actions/Transaction'; import {clearTwoFactorAuthData} from '@libs/actions/TwoFactorAuthActions'; @@ -49,18 +50,15 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { } = useContext(WideRHPContext); const {windowWidth} = useWindowDimensions(); const modalCardStyleInterpolator = useModalCardStyleInterpolator(); + const styles = useThemeStyles(); const animatedWidth = expandedRHPProgress.interpolate({ inputRange: [0, 1, 2], outputRange: [singleRHPWidth, getWideRHPWidth(windowWidth), calculateSuperWideRHPWidth(windowWidth)], }); - const animatedStyle = useMemo(() => { + const animatedWidthStyle = useMemo(() => { return { - height: '100%', - right: 0, - position: 'absolute', - overflow: 'hidden', width: shouldUseNarrowLayout ? '100%' : animatedWidth, } as const; }, [animatedWidth, shouldUseNarrowLayout]); @@ -103,7 +101,7 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { {!shouldUseNarrowLayout && } {/* This one is to limit the outer Animated.View and allow the background to be pressable */} {/* Without it, the transparent half of the narrow format RHP card would cover the pressable part of the overlay */} - + Date: Mon, 17 Nov 2025 17:26:12 +0100 Subject: [PATCH 36/64] Add docs for overlays displayed in RightModalNavigator --- .../AppNavigator/Navigators/RightModalNavigator.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index 7ce605a37992..237c12afed52 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -317,8 +317,9 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { /> - {/* The second overlay is here to cover the wide rhp screen underneath */} - {/* It has a gap on the right to make the last rhp route (narrow) visible and pressable */} + {/* The third and second overlays are displayed here to cover RHP screens wider than the currently focused screen. */} + {/* Clicking on these overlays redirects you to the RHP screen below them. */} + {/* The width of these overlays is equal to the width of the screen minus the width of the currently focused RHP screen (positionRightValue) */} {shouldRenderSecondaryOverlay && !shouldUseNarrowLayout && !isWideRHPFocused && !isWideRHPClosing && ( Date: Mon, 17 Nov 2025 18:12:14 +0100 Subject: [PATCH 37/64] Add docs for overlays displayed in ModalStackNavigators --- .../ModalStackNavigators/index.tsx | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index b913da66780a..d6fafc1ee739 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -1,6 +1,6 @@ import {useIsFocused, useRoute} from '@react-navigation/native'; import type {ParamListBase} from '@react-navigation/routers'; -import React, {useCallback, useContext} from 'react'; +import React, {useCallback, useContext, useMemo} from 'react'; import {View} from 'react-native'; import {modalStackOverlaySuperWideRHPWidth, modalStackOverlayWideRHPWidth, receiptPaneRHPWidth, WideRHPContext} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; @@ -126,6 +126,21 @@ function createModalStackNavigator(screens: Scr [screenOptions], ); + const isRHPDisplayedOnWideRHP = useMemo( + () => + !isSmallScreenWidth && + !isWideRHPFocused && + !isWideRHPClosing && + !isFocused && + shouldRenderSecondaryOverlay && + (isSuperWideRHPRouteName(route.name) || isWideRHPRouteName(route.name)), + [isFocused, isSmallScreenWidth, isWideRHPClosing, isWideRHPFocused, route.name, shouldRenderSecondaryOverlay], + ); + const isWideRHPDisplayedOnSuperWideRHP = useMemo( + () => !isSmallScreenWidth && !isFocused && !!isWideRHPFocused && shouldRenderSecondaryOverlay && isSuperWideRHPRouteName(route.name), + [isFocused, isSmallScreenWidth, isWideRHPFocused, route.name, shouldRenderSecondaryOverlay], + ); + return ( // This container is necessary to hide card translation during transition. Without it the user would see un-clipped cards. @@ -140,25 +155,28 @@ function createModalStackNavigator(screens: Scr /> ))} - {!isSmallScreenWidth && shouldRenderSecondaryOverlay && isWideRHPRouteName(route.name) && !isFocused && !isWideRHPClosing && !shouldRenderTertiaryOverlay ? ( - // This overlay is necessary to cover the gap under the narrow format RHP screen + {/* These overlays are used to cover the space under the narrower RHP screen when more than one RHP width is displayed on the screen */} + {/* Their position is calculated as follows: */} + {/* The width of the window for which we calculate the overlay positions is the width of the RHP window, for example for Super Wide RHP it will be 1260 px on a wide layout. */} + {/* We need to move the overlay left from the left edge of the RHP below to the left edge of the RHP above. */} + {/* To calculate this, subtract the width of the widest RHP from the width of the RHP above. */} + {/* Two cases were described for the secondary overlay: */} + {/* 1. Single RHP is displayed on Wide RHP (Super Wide or Wide) - here we additionaly check superWideRHPRouteKeys length as Super Wide RHP route might be dsiplayed in Wide RHP when number of visible transactions is less than 2. */} + {/* 2. Wide RHP is displayed on Super Wide RHP route. */} + {/* Please note that in these cases, the overlay is rendered from the RHP screen displayed below. For example, if we display RHP on Wide RHP, the secondary overlay is rendered from Wide RHP, etc. */} + {/* There is also a special case where three different RHP widths are displayed at the same time. In this case, an overlay under RHP should be rendered from Wide RHP. */} + {isRHPDisplayedOnWideRHP ? ( 0 ? modalStackOverlaySuperWideRHPWidth : receiptPaneRHPWidth} /> ) : null} - {!isSmallScreenWidth && shouldRenderSecondaryOverlay && isSuperWideRHPRouteName(route.name) && !!isWideRHPFocused && !isFocused ? ( + {isWideRHPDisplayedOnSuperWideRHP ? ( ) : null} - {!isSmallScreenWidth && shouldRenderSecondaryOverlay && isSuperWideRHPRouteName(route.name) && !isWideRHPFocused && !isFocused ? ( - 0 ? modalStackOverlaySuperWideRHPWidth : receiptPaneRHPWidth} - /> - ) : null} {!isSmallScreenWidth && shouldRenderTertiaryOverlay && isWideRHPRouteName(route.name) ? ( Date: Mon, 17 Nov 2025 18:54:38 +0100 Subject: [PATCH 38/64] Simplify WideRHPContextProvider logic --- .../WideRHPContextProvider/index.native.tsx | 4 +- .../WideRHPContextProvider/index.tsx | 143 +++++++++--------- .../ModalStackNavigators/index.tsx | 4 +- .../Navigators/RightModalNavigator.tsx | 4 +- src/styles/index.ts | 10 +- 5 files changed, 86 insertions(+), 79 deletions(-) diff --git a/src/components/WideRHPContextProvider/index.native.tsx b/src/components/WideRHPContextProvider/index.native.tsx index 96c955d933d7..d2bad9ae382f 100644 --- a/src/components/WideRHPContextProvider/index.native.tsx +++ b/src/components/WideRHPContextProvider/index.native.tsx @@ -8,7 +8,7 @@ import type {WideRHPContextType} from './types'; const expandedRHPProgress = new Animated.Value(0); const secondOverlayProgress = new Animated.Value(0); -const receiptPaneRHPWidth = new Animated.Value(0); +const animatedReceiptPaneRHPWidth = new Animated.Value(0); const WideRHPContext = createContext(defaultWideRHPContextValue); @@ -24,4 +24,4 @@ WideRHPContextProvider.displayName = 'WideRHPContextProvider'; export default WideRHPContextProvider; export type {WideRHPContextType}; -export {expandedRHPProgress, secondOverlayProgress, WideRHPContext, useShowWideRHPVersion, receiptPaneRHPWidth}; +export {expandedRHPProgress, secondOverlayProgress, WideRHPContext, useShowWideRHPVersion, animatedReceiptPaneRHPWidth}; diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 9f0ebc6397d1..8fcce690a9e1 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -26,9 +26,6 @@ const innerRHPProgress = new Animated.Value(0); const secondOverlayProgress = new Animated.Value(0); const thirdOverlayProgress = new Animated.Value(0); -const singleRHPWidth = variables.sideBarWidth; -const wideRHPMaxWidth = variables.receiptPaneRHPMaxWidth + singleRHPWidth; - const OVERLAY_TIMING_DURATION = 300; // This array includes wide and super wide right modals @@ -75,6 +72,9 @@ function extractNavigationKeys(state: NavigationState | PartialState { return Math.max(Math.min(superWideRHPWidth, variables.superWideRHPMaxWidth), wideRHPWidth); }; -// This animated value is necessary to have a responsive RHP width for the range 800px to 840px. -const receiptPaneRHPWidth = new Animated.Value(calculateReceiptPaneRHPWidth(Dimensions.get('window').width)); -const superWideRHPWidth = new Animated.Value(calculateSuperWideRHPWidth(Dimensions.get('window').width)); +const receiptPaneRHPWidth = calculateReceiptPaneRHPWidth(Dimensions.get('window').width); +const superWideRHPWidth = calculateReceiptPaneRHPWidth(Dimensions.get('window').width); +const wideRHPWidth = receiptPaneRHPWidth + singleRHPWidth; -const wideRHPWidth = new Animated.Value(calculateReceiptPaneRHPWidth(Dimensions.get('window').width) + singleRHPWidth); -const modalStackOverlayWideRHPWidth = new Animated.Value( - calculateSuperWideRHPWidth(Dimensions.get('window').width) - calculateReceiptPaneRHPWidth(Dimensions.get('window').width - singleRHPWidth), -); -const modalStackOverlaySuperWideRHPWidth = new Animated.Value(calculateSuperWideRHPWidth(Dimensions.get('window').width) - singleRHPWidth); +// This animated value is necessary to have responsive RHP widths +const animatedReceiptPaneRHPWidth = new Animated.Value(receiptPaneRHPWidth); +const animatedSuperWideRHPWidth = new Animated.Value(superWideRHPWidth); +const animatedWideRHPWidth = new Animated.Value(wideRHPWidth); +const modalStackOverlayWideRHPWidth = new Animated.Value(superWideRHPWidth - wideRHPWidth); +const modalStackOverlaySuperWideRHPWidth = new Animated.Value(superWideRHPWidth - singleRHPWidth); const WideRHPContext = createContext(defaultWideRHPContextValue); @@ -183,72 +184,78 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { return !!focusedRouteKey && wideRHPRouteKeys.includes(focusedRouteKey); }, [focusedRouteKey, wideRHPRouteKeys]); - /** - * Determines whether the secondary overlay should be displayed. - * Shows second overlay when RHP is open and there is a wide RHP route open but there is another regular route on the top. - */ - const shouldShowSecondaryOverlay = useRootNavigationState((state) => { - // Safe handling when navigation is not yet initialized - if (!state) { - return false; - } + const getIsSuperWideRHPBelowFocusedScreen = useCallback( + (state: NavigationState | undefined) => { + if (!state) { + return false; + } - const focusedRoute = findFocusedRoute(state); - const isRHPLastRootRoute = state?.routes.at(-1)?.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR; - const currentLastVisibleRHPRouteKey = getLastVisibleRHPRouteKey(state); - const currentWideRHPRouteKeys = getCurrentWideRHPKeys(allWideRHPRouteKeys, currentLastVisibleRHPRouteKey); - const currentSuperWideRHPRouteKeys = getCurrentWideRHPKeys(allSuperWideRHPRouteKeys, currentLastVisibleRHPRouteKey); + const focusedRoute = findFocusedRoute(state); - // Shouldn't ever happen but for type safety - if (!focusedRoute?.key) { - return false; - } + // Shouldn't ever happen but for type safety + if (!focusedRoute?.key) { + return false; + } - const isFocusedRouteSuperWide = isSuperWideRHPRouteName(focusedRoute.name); + const currentLastVisibleRHPRouteKey = getLastVisibleRHPRouteKey(state); + const currentSuperWideRHPRouteKeys = getCurrentWideRHPKeys(allSuperWideRHPRouteKeys, currentLastVisibleRHPRouteKey); + const isFocusedRouteSuperWide = isSuperWideRHPRouteName(focusedRoute.name); - // This screen is always first in RHP, so secondary overlay is not displayed in this case. - if (isFocusedRouteSuperWide) { - return false; - } + return currentSuperWideRHPRouteKeys.length > 0 && !currentSuperWideRHPRouteKeys.includes(focusedRoute.key) && !isFocusedRouteSuperWide; + }, + [allSuperWideRHPRouteKeys], + ); - if (currentSuperWideRHPRouteKeys.includes(focusedRoute.key) && currentWideRHPRouteKeys.length > 0) { - return false; - } + const getIsWideRHPBelowFocusedScreen = useCallback( + (state: NavigationState | undefined) => { + if (!state) { + return false; + } - if (currentSuperWideRHPRouteKeys.length > 0 && !currentSuperWideRHPRouteKeys.includes(focusedRoute.key) && isRHPLastRootRoute && !isFocusedRouteSuperWide) { - return true; - } + const focusedRoute = findFocusedRoute(state); - // Check the focused route to avoid glitching when quickly close and open RHP. - if (currentWideRHPRouteKeys.length > 0 && !currentWideRHPRouteKeys.includes(focusedRoute.key) && isRHPLastRootRoute && focusedRoute.name !== SCREENS.SEARCH.REPORT_RHP) { - return true; - } + // Shouldn't ever happen but for type safety + if (!focusedRoute?.key) { + return false; + } - return false; - }); + const currentLastVisibleRHPRouteKey = getLastVisibleRHPRouteKey(state); + const currentWideRHPRouteKeys = getCurrentWideRHPKeys(allWideRHPRouteKeys, currentLastVisibleRHPRouteKey); + const isFocusedRouteWide = focusedRoute.name === SCREENS.SEARCH.REPORT_RHP; - const shouldShowThirdOverlay = useRootNavigationState((state) => { - // Safe handling when navigation is not yet initialized - if (!state) { + return currentWideRHPRouteKeys.length > 0 && !currentWideRHPRouteKeys.includes(focusedRoute.key) && !isFocusedRouteWide; + }, + [allWideRHPRouteKeys], + ); + + /** + * Determines whether the secondary overlay should be displayed. + */ + const shouldShowSecondaryOverlay = useRootNavigationState((state) => { + const isRHPLastRootRoute = state?.routes.at(-1)?.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR; + + if (!isRHPLastRootRoute) { return false; } - const focusedRoute = findFocusedRoute(state); + const isSuperWideRHPBelow = getIsSuperWideRHPBelowFocusedScreen(state); + const isWideRHPBelow = getIsWideRHPBelowFocusedScreen(state); + return isSuperWideRHPBelow || isWideRHPBelow; + }); + + /** + * Determines whether the tertiary overlay should be displayed. + */ + const shouldShowTertiaryOverlay = useRootNavigationState((state) => { const isRHPLastRootRoute = state?.routes.at(-1)?.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR; - const currentLastVisibleRHPRouteKey = getLastVisibleRHPRouteKey(state); - const currentSuperWideRHPRouteKeys = getCurrentWideRHPKeys(allSuperWideRHPRouteKeys, currentLastVisibleRHPRouteKey); - // Shouldn't ever happen but for type safety - if (!focusedRoute?.key) { + if (!isRHPLastRootRoute) { return false; } - const isSuperWideRhpDisplayedBelow = - currentSuperWideRHPRouteKeys.length > 0 && !currentSuperWideRHPRouteKeys.includes(focusedRoute.key) && !isSuperWideRHPRouteName(focusedRoute.name); - const isWideRhpDisplayedBelow = wideRHPRouteKeys.length > 0 && !wideRHPRouteKeys.includes(focusedRoute.key) && focusedRoute.name !== SCREENS.SEARCH.REPORT_RHP; - - // Check the focused route to avoid glitching when quickly close and open RHP. - return isSuperWideRhpDisplayedBelow && isWideRhpDisplayedBelow && isRHPLastRootRoute; + const isSuperWideRHPBelow = getIsSuperWideRHPBelowFocusedScreen(state); + const isWideRHPBelow = getIsWideRHPBelowFocusedScreen(state); + return isSuperWideRHPBelow && isWideRHPBelow; }); /** @@ -434,7 +441,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { * Effect that manages the secondary overlay animation and rendering state. */ useEffect(() => { - if (shouldShowThirdOverlay) { + if (shouldShowTertiaryOverlay) { setShouldRenderTertiaryOverlay(true); Animated.timing(thirdOverlayProgress, { toValue: 1, @@ -450,7 +457,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { setShouldRenderTertiaryOverlay(false); }); } - }, [shouldShowThirdOverlay]); + }, [shouldShowTertiaryOverlay]); /** * Effect that handles responsive RHP width calculation when window dimensions change. @@ -462,11 +469,11 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const newReceiptPaneRHPWidth = calculateReceiptPaneRHPWidth(windowWidth); const newSuperWideRHPWidth = calculateSuperWideRHPWidth(windowWidth); const newWideRHPWidth = newReceiptPaneRHPWidth + singleRHPWidth; - receiptPaneRHPWidth.setValue(newReceiptPaneRHPWidth); - wideRHPWidth.setValue(newWideRHPWidth); + animatedReceiptPaneRHPWidth.setValue(newReceiptPaneRHPWidth); + animatedWideRHPWidth.setValue(newWideRHPWidth); modalStackOverlayWideRHPWidth.setValue(newSuperWideRHPWidth - newWideRHPWidth); modalStackOverlaySuperWideRHPWidth.setValue(newSuperWideRHPWidth - singleRHPWidth); - superWideRHPWidth.setValue(newSuperWideRHPWidth); + animatedSuperWideRHPWidth.setValue(newSuperWideRHPWidth); }; // Set initial value @@ -604,14 +611,14 @@ export { calculateReceiptPaneRHPWidth, calculateSuperWideRHPWidth, extractNavigationKeys, - superWideRHPWidth, + animatedSuperWideRHPWidth, modalStackOverlaySuperWideRHPWidth, modalStackOverlayWideRHPWidth, - receiptPaneRHPWidth, + animatedReceiptPaneRHPWidth, secondOverlayProgress, useShowSuperWideRHPVersion, useShowWideRHPVersion, WideRHPContext, - wideRHPWidth, + animatedWideRHPWidth, innerRHPProgress, }; diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index d6fafc1ee739..4a11a921799c 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -2,7 +2,7 @@ import {useIsFocused, useRoute} from '@react-navigation/native'; import type {ParamListBase} from '@react-navigation/routers'; import React, {useCallback, useContext, useMemo} from 'react'; import {View} from 'react-native'; -import {modalStackOverlaySuperWideRHPWidth, modalStackOverlayWideRHPWidth, receiptPaneRHPWidth, WideRHPContext} from '@components/WideRHPContextProvider'; +import {modalStackOverlaySuperWideRHPWidth, modalStackOverlayWideRHPWidth, animatedReceiptPaneRHPWidth, WideRHPContext} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import Overlay from '@libs/Navigation/AppNavigator/Navigators/Overlay'; @@ -168,7 +168,7 @@ function createModalStackNavigator(screens: Scr {isRHPDisplayedOnWideRHP ? ( 0 ? modalStackOverlaySuperWideRHPWidth : receiptPaneRHPWidth} + positionLeftValue={superWideRHPRouteKeys.length > 0 ? modalStackOverlaySuperWideRHPWidth : animatedReceiptPaneRHPWidth} /> ) : null} {isWideRHPDisplayedOnSuperWideRHP ? ( diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index 237c12afed52..20b970b4f508 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -4,7 +4,7 @@ import React, {useCallback, useContext, useMemo, useRef} from 'react'; // eslint-disable-next-line no-restricted-imports import {Animated, InteractionManager} from 'react-native'; import NoDropZone from '@components/DragAndDrop/NoDropZone'; -import {calculateReceiptPaneRHPWidth, calculateSuperWideRHPWidth, innerRHPProgress, WideRHPContext, wideRHPWidth} from '@components/WideRHPContextProvider'; +import {calculateReceiptPaneRHPWidth, calculateSuperWideRHPWidth, innerRHPProgress, WideRHPContext, animatedWideRHPWidth} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; @@ -330,7 +330,7 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { {shouldRenderSecondaryOverlay && !shouldUseNarrowLayout && !!isWideRHPFocused && ( )} diff --git a/src/styles/index.ts b/src/styles/index.ts index 8a018125afc5..505684bd938a 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -14,7 +14,7 @@ import type {MixedStyleDeclaration, MixedStyleRecord} from 'react-native-render- import type {ValueOf} from 'type-fest'; import type DotLottieAnimation from '@components/LottieAnimations/types'; import {ACTIVE_LABEL_SCALE} from '@components/TextInput/styleConst'; -import {receiptPaneRHPWidth, superWideRHPWidth, wideRHPWidth} from '@components/WideRHPContextProvider'; +import {animatedReceiptPaneRHPWidth, animatedSuperWideRHPWidth, animatedWideRHPWidth} from '@components/WideRHPContextProvider'; import {getBrowser, isMobile, isMobileSafari, isSafari} from '@libs/Browser'; import getPlatform from '@libs/getPlatform'; import CONST from '@src/CONST'; @@ -5354,14 +5354,14 @@ const staticStyles = (theme: ThemeColors) => position: Platform.OS === 'web' ? 'fixed' : 'absolute', height: '100%', right: 0, - width: wideRHPWidth, + width: animatedWideRHPWidth, }, superWideRHPExtendedCardInterpolatorStyles: { position: Platform.OS === 'web' ? 'fixed' : 'absolute', height: '100%', right: 0, - width: superWideRHPWidth, + width: animatedSuperWideRHPWidth, }, flexibleHeight: { @@ -5375,7 +5375,7 @@ const staticStyles = (theme: ThemeColors) => wideRHPMoneyRequestReceiptViewContainer: { backgroundColor: theme.appBG, - width: receiptPaneRHPWidth, + width: animatedReceiptPaneRHPWidth, height: '100%', borderRightWidth: 1, borderColor: theme.border, @@ -5582,7 +5582,7 @@ const dynamicStyles = (theme: ThemeColors) => animatedRHPNavigatorContainerWidth: (shouldUseNarrowLayout: boolean, expandedRHPProgress: Animated.Value) => ({ - width: shouldUseNarrowLayout ? '100%' : Animated.add(variables.sideBarWidth, Animated.multiply(expandedRHPProgress, receiptPaneRHPWidth)), + width: shouldUseNarrowLayout ? '100%' : Animated.add(variables.sideBarWidth, Animated.multiply(expandedRHPProgress, animatedReceiptPaneRHPWidth)), }) satisfies ViewStyle, OnboardingNavigatorInnerView: (shouldUseNarrowLayout: boolean) => From fa43422daec7277e6b6405e4addd899fd5aeb720 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Tue, 18 Nov 2025 09:29:18 +0100 Subject: [PATCH 39/64] Adjust default values and types in WideRHPContextProvider --- .../WideRHPContextProvider/default.ts | 7 ---- .../WideRHPContextProvider/index.native.tsx | 40 ++++++++++++++++++- .../WideRHPContextProvider/index.tsx | 5 +-- .../WideRHPContextProvider/types.ts | 11 ----- .../ModalStackNavigators/index.tsx | 14 +++++-- .../Navigators/RightModalNavigator.tsx | 25 +++++------- .../useRootNavigatorScreenOptions.ts | 4 +- 7 files changed, 62 insertions(+), 44 deletions(-) diff --git a/src/components/WideRHPContextProvider/default.ts b/src/components/WideRHPContextProvider/default.ts index cb8529ce0c9c..d71e0e6b7f47 100644 --- a/src/components/WideRHPContextProvider/default.ts +++ b/src/components/WideRHPContextProvider/default.ts @@ -1,13 +1,7 @@ -// We use Animated for all functionality related to wide RHP to make it easier -// to interact with react-navigation components (e.g., CardContainer, interpolator), which also use Animated. -// eslint-disable-next-line no-restricted-imports -import {Animated} from 'react-native'; import type {WideRHPContextType} from './types'; const defaultWideRHPContextValue: WideRHPContextType = { wideRHPRouteKeys: [], - expandedRHPProgress: new Animated.Value(0), - secondOverlayProgress: new Animated.Value(0), shouldRenderSecondaryOverlay: false, showWideRHPVersion: () => {}, cleanWideRHPRouteKey: () => {}, @@ -21,7 +15,6 @@ const defaultWideRHPContextValue: WideRHPContextType = { shouldRenderTertiaryOverlay: false, superWideRHPRouteKeys: [], showSuperWideRHPVersion: () => {}, - thirdOverlayProgress: new Animated.Value(0), }; export default defaultWideRHPContextValue; diff --git a/src/components/WideRHPContextProvider/index.native.tsx b/src/components/WideRHPContextProvider/index.native.tsx index d2bad9ae382f..7b59a15e740e 100644 --- a/src/components/WideRHPContextProvider/index.native.tsx +++ b/src/components/WideRHPContextProvider/index.native.tsx @@ -6,9 +6,18 @@ import {Animated} from 'react-native'; import defaultWideRHPContextValue from './default'; import type {WideRHPContextType} from './types'; -const expandedRHPProgress = new Animated.Value(0); const secondOverlayProgress = new Animated.Value(0); +const thirdOverlayProgress = new Animated.Value(0); + const animatedReceiptPaneRHPWidth = new Animated.Value(0); +const animatedWideRHPWidth = new Animated.Value(0); +const animatedSuperWideRHPWidth = new Animated.Value(0); + +const modalStackOverlaySuperWideRHPWidth = new Animated.Value(0); +const modalStackOverlayWideRHPWidth = new Animated.Value(0); + +const expandedRHPProgress = new Animated.Value(0); +const innerRHPProgress = new Animated.Value(0); const WideRHPContext = createContext(defaultWideRHPContextValue); @@ -20,8 +29,35 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { // eslint-disable-next-line @typescript-eslint/no-unused-vars function useShowWideRHPVersion(condition: boolean) {} +// Super Wide RHP is not displayed on native platforms +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function useShowSuperWideRHPVersion(condition: boolean) {} + +// Wide RHP is not displayed on native platforms +// eslint-disable-next-line @typescript-eslint/no-unused-vars +const calculateReceiptPaneRHPWidth = (windowWidth: number) => {}; + +// Super Wide RHP is not displayed on native platforms +// eslint-disable-next-line @typescript-eslint/no-unused-vars +const calculateSuperWideRHPWidth = (windowWidth: number) => {}; + WideRHPContextProvider.displayName = 'WideRHPContextProvider'; export default WideRHPContextProvider; export type {WideRHPContextType}; -export {expandedRHPProgress, secondOverlayProgress, WideRHPContext, useShowWideRHPVersion, animatedReceiptPaneRHPWidth}; +export { + calculateReceiptPaneRHPWidth, + calculateSuperWideRHPWidth, + animatedSuperWideRHPWidth, + modalStackOverlaySuperWideRHPWidth, + modalStackOverlayWideRHPWidth, + animatedReceiptPaneRHPWidth, + secondOverlayProgress, + thirdOverlayProgress, + useShowSuperWideRHPVersion, + useShowWideRHPVersion, + WideRHPContext, + animatedWideRHPWidth, + innerRHPProgress, + expandedRHPProgress, +}; diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 8fcce690a9e1..8fe75d542eb2 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -494,8 +494,6 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { showWideRHPVersion, showSuperWideRHPVersion, cleanWideRHPRouteKey, - secondOverlayProgress, - thirdOverlayProgress, shouldRenderSecondaryOverlay, shouldRenderTertiaryOverlay, dismissToFirstRHP, @@ -610,15 +608,16 @@ export default WideRHPContextProvider; export { calculateReceiptPaneRHPWidth, calculateSuperWideRHPWidth, - extractNavigationKeys, animatedSuperWideRHPWidth, modalStackOverlaySuperWideRHPWidth, modalStackOverlayWideRHPWidth, animatedReceiptPaneRHPWidth, secondOverlayProgress, + thirdOverlayProgress, useShowSuperWideRHPVersion, useShowWideRHPVersion, WideRHPContext, animatedWideRHPWidth, innerRHPProgress, + expandedRHPProgress, }; diff --git a/src/components/WideRHPContextProvider/types.ts b/src/components/WideRHPContextProvider/types.ts index dfbbed000999..37cacdb5592e 100644 --- a/src/components/WideRHPContextProvider/types.ts +++ b/src/components/WideRHPContextProvider/types.ts @@ -1,5 +1,3 @@ -// eslint-disable-next-line no-restricted-imports -import type {Animated} from 'react-native'; import type {NavigationRoute} from '@libs/Navigation/types'; type WideRHPContextType = { @@ -9,15 +7,6 @@ type WideRHPContextType = { // Route keys of screens that should be displayed in super wide format superWideRHPRouteKeys: string[]; - // Progress of changing format: 0 - narrow, 1 - wide, 2 - super-wide - expandedRHPProgress: Animated.Value; - - // Progress of the secondary overlay, the one covering wider RHP screen - secondOverlayProgress: Animated.Value; - - // Progress of the tertiary overlay, the one covering wider RHP screen - thirdOverlayProgress: Animated.Value; - // If the secondary overlay should be rendered. This value takes into account the delay of closing transition. shouldRenderSecondaryOverlay: boolean; diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 4a11a921799c..d57623711089 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -2,7 +2,14 @@ import {useIsFocused, useRoute} from '@react-navigation/native'; import type {ParamListBase} from '@react-navigation/routers'; import React, {useCallback, useContext, useMemo} from 'react'; import {View} from 'react-native'; -import {modalStackOverlaySuperWideRHPWidth, modalStackOverlayWideRHPWidth, animatedReceiptPaneRHPWidth, WideRHPContext} from '@components/WideRHPContextProvider'; +import { + animatedReceiptPaneRHPWidth, + modalStackOverlaySuperWideRHPWidth, + modalStackOverlayWideRHPWidth, + secondOverlayProgress, + thirdOverlayProgress, + WideRHPContext, +} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import Overlay from '@libs/Navigation/AppNavigator/Navigators/Overlay'; @@ -105,8 +112,7 @@ function createModalStackNavigator(screens: Scr function ModalStack() { const styles = useThemeStyles(); const screenOptions = useModalStackScreenOptions(); - const {secondOverlayProgress, shouldRenderSecondaryOverlay, thirdOverlayProgress, shouldRenderTertiaryOverlay, isWideRHPFocused, superWideRHPRouteKeys, isWideRHPClosing} = - useContext(WideRHPContext); + const {shouldRenderSecondaryOverlay, shouldRenderTertiaryOverlay, isWideRHPFocused, superWideRHPRouteKeys, isWideRHPClosing} = useContext(WideRHPContext); const route = useRoute(); const isFocused = useIsFocused(); @@ -161,7 +167,7 @@ function createModalStackNavigator(screens: Scr {/* We need to move the overlay left from the left edge of the RHP below to the left edge of the RHP above. */} {/* To calculate this, subtract the width of the widest RHP from the width of the RHP above. */} {/* Two cases were described for the secondary overlay: */} - {/* 1. Single RHP is displayed on Wide RHP (Super Wide or Wide) - here we additionaly check superWideRHPRouteKeys length as Super Wide RHP route might be dsiplayed in Wide RHP when number of visible transactions is less than 2. */} + {/* 1. Single RHP is displayed on Wide RHP (Super Wide or Wide) - here we additionally check the length of superWideRHPRouteKeys because Super Wide RHP route can also be displayed in Wide RHP when the number of visible transactions is less than 2. */} {/* 2. Wide RHP is displayed on Super Wide RHP route. */} {/* Please note that in these cases, the overlay is rendered from the RHP screen displayed below. For example, if we display RHP on Wide RHP, the secondary overlay is rendered from Wide RHP, etc. */} {/* There is also a special case where three different RHP widths are displayed at the same time. In this case, an overlay under RHP should be rendered from Wide RHP. */} diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index 20b970b4f508..4afc5ff99a04 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -4,7 +4,16 @@ import React, {useCallback, useContext, useMemo, useRef} from 'react'; // eslint-disable-next-line no-restricted-imports import {Animated, InteractionManager} from 'react-native'; import NoDropZone from '@components/DragAndDrop/NoDropZone'; -import {calculateReceiptPaneRHPWidth, calculateSuperWideRHPWidth, innerRHPProgress, WideRHPContext, animatedWideRHPWidth} from '@components/WideRHPContextProvider'; +import { + animatedWideRHPWidth, + calculateReceiptPaneRHPWidth, + calculateSuperWideRHPWidth, + expandedRHPProgress, + innerRHPProgress, + secondOverlayProgress, + thirdOverlayProgress, + WideRHPContext, +} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; @@ -15,7 +24,6 @@ import * as ModalStackNavigators from '@libs/Navigation/AppNavigator/ModalStackN import useModalCardStyleInterpolator from '@libs/Navigation/AppNavigator/useModalCardStyleInterpolator'; import useRHPScreenOptions from '@libs/Navigation/AppNavigator/useRHPScreenOptions'; import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; -import Presentation from '@libs/Navigation/PlatformStackNavigation/navigationOptions/presentation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {AuthScreensParamList, RightModalNavigatorParamList} from '@navigation/types'; import variables from '@styles/variables'; @@ -37,17 +45,7 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { const {shouldUseNarrowLayout, isSmallScreenWidth} = useResponsiveLayout(); const isExecutingRef = useRef(false); const screenOptions = useRHPScreenOptions(); - const { - expandedRHPProgress, - shouldRenderSecondaryOverlay, - secondOverlayProgress, - isWideRHPFocused, - shouldRenderTertiaryOverlay, - thirdOverlayProgress, - isWideRHPClosing, - dismissToFirstRHP, - dismissToSecondRHP, - } = useContext(WideRHPContext); + const {shouldRenderSecondaryOverlay, isWideRHPFocused, shouldRenderTertiaryOverlay, isWideRHPClosing, dismissToFirstRHP, dismissToSecondRHP} = useContext(WideRHPContext); const {windowWidth} = useWindowDimensions(); const modalCardStyleInterpolator = useModalCardStyleInterpolator(); const styles = useThemeStyles(); @@ -262,7 +260,6 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { name={SCREENS.RIGHT_MODAL.SEARCH_REPORT} component={ModalStackNavigators.SearchReportModalStackNavigator} options={{ - presentation: Presentation.TRANSPARENT_MODAL, web: { cardStyleInterpolator: (props: StackCardInterpolationProps) => // Add 1 to change range from [0, 1] to [1, 2] diff --git a/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts b/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts index fcc5c8a1934d..cee832614336 100644 --- a/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts +++ b/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts @@ -1,10 +1,9 @@ import type {StackCardInterpolationProps} from '@react-navigation/stack'; -import {useContext} from 'react'; // We use Animated for all functionality related to wide RHP to make it easier // to interact with react-navigation components (e.g., CardContainer, interpolator), which also use Animated. // eslint-disable-next-line no-restricted-imports import {Animated} from 'react-native'; -import {calculateSuperWideRHPWidth, WideRHPContext} from '@components/WideRHPContextProvider'; +import {calculateSuperWideRHPWidth, expandedRHPProgress} from '@components/WideRHPContextProvider'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -44,7 +43,6 @@ const useRootNavigatorScreenOptions = () => { // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth const {isSmallScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout(); const themeStyles = useThemeStyles(); - const {expandedRHPProgress} = useContext(WideRHPContext); const {windowWidth} = useWindowDimensions(); return { From 06ac45aa6617b72ff461bd0c6c8d497851ad526c Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Tue, 18 Nov 2025 10:46:50 +0100 Subject: [PATCH 40/64] Add docs for outputRangeMultiplier for rightModalNavigator --- .../AppNavigator/useRootNavigatorScreenOptions.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts b/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts index cee832614336..69248b5b2e59 100644 --- a/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts +++ b/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts @@ -55,13 +55,19 @@ const useRootNavigatorScreenOptions = () => { web: { presentation: Presentation.TRANSPARENT_MODAL, cardStyleInterpolator: (props: StackCardInterpolationProps) => - // Add 1 to change range from [0, 1] to [1, 2] // Don't use outputMultiplier for the narrow layout modalCardStyleInterpolator({ props, shouldAnimateSidePanel: true, - - // Adjust output range to match the wide RHP size + // On a wide layout, the output range multiplier is multiplied inside useModalCardStyleInterpolator by the width of a single RHP. + // Depending on the value of expandedRHPProgress, after multiplication the appropriate RHP width should be obtained. + // To achieve this, the following function was used: + // y = (1 - |x - 1|) * receiptPaneWidth/sidebarWidth + Max((x - 1), 0)) * (superWideRHPWidth / sidebarWidth - 1) + 1 + // For expandedRHPProgress equal to: + // 0 - Single RHP, y = 1 + // 1 - Wide RHP, y = receiptPaneWidth / sidebarWidth + 1 + // 2 - Super Wide RHP, y = superWideRHPWidth / sidebarWidth + // For the given values, after multiplying by sidebarWidth inside useModalCardStyleInterpolator, the correct widths ​​are obtained outputRangeMultiplier: isSmallScreenWidth ? undefined : Animated.add( @@ -69,7 +75,7 @@ const useRootNavigatorScreenOptions = () => { Animated.multiply(Animated.subtract(1, abs(Animated.subtract(1, expandedRHPProgress))), variables.receiptPaneRHPMaxWidth / variables.sideBarWidth), Animated.multiply( expandedRHPProgress.interpolate({inputRange: [1, 2], outputRange: [0, 1], extrapolate: 'clamp'}), - (calculateSuperWideRHPWidth(windowWidth) - variables.sideBarWidth) / variables.sideBarWidth, + calculateSuperWideRHPWidth(windowWidth) / variables.sideBarWidth - 1, ), ), 1, From f3bed8062b86adce4dfd3b6daaa04822023a1122 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Tue, 18 Nov 2025 11:00:59 +0100 Subject: [PATCH 41/64] Handle e/:reportID url when sending data about opened report to sentry --- src/libs/Navigation/Navigation.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/libs/Navigation/Navigation.ts b/src/libs/Navigation/Navigation.ts index bf40c00d2b17..af7f5f826588 100644 --- a/src/libs/Navigation/Navigation.ts +++ b/src/libs/Navigation/Navigation.ts @@ -197,11 +197,16 @@ function navigate(route: Route, options?: LinkToOptions) { } // Start a Sentry span for report navigation - if (route.startsWith('r/') || route.startsWith('search/r/')) { - const reportIDMatch = route.match(/^(?:search\/)?r\/(\w+)/); - if (reportIDMatch?.at(1)) { - const reportID = reportIDMatch.at(1); - const spanName = route.startsWith('r/') ? '/r/*' : '/search/r/*'; + if (route.startsWith('r/') || route.startsWith('search/r/') || route.startsWith('e/')) { + const reportIDMatch = route.match(/^(?:search\/)?(?:r|e)\/(\w+)/); + const reportID = reportIDMatch?.at(1); + if (reportID) { + let spanName = '/r/*'; + if (route.startsWith('search/r/')) { + spanName = '/search/r/*'; + } else if (route.startsWith('e/')) { + spanName = '/e/*'; + } startSpan(`${CONST.TELEMETRY.SPAN_OPEN_REPORT}_${reportID}`, { name: spanName, op: CONST.TELEMETRY.SPAN_OPEN_REPORT, @@ -211,10 +216,8 @@ function navigate(route: Route, options?: LinkToOptions) { }); } } - linkTo(navigationRef.current, route, options); } - /** * When routes are compared to determine whether the fallback route passed to the goUp function is in the state, * these parameters shouldn't be included in the comparison. From fc4ad271458b10f932a798d100a3c247f1d117de Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Tue, 18 Nov 2025 11:08:36 +0100 Subject: [PATCH 42/64] Simplify setting rhp progress values --- src/components/WideRHPContextProvider/index.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 8fe75d542eb2..f2efdc412aa6 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -400,15 +400,15 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { * Effect that shows/hides the expanded RHP progress based on the number of wide RHP routes. */ useEffect(() => { - if (superWideRHPRouteKeys.length > 0) { + const numberOfSuperWideRoutes = superWideRHPRouteKeys.length; + const numberOfWideRoutes = wideRHPRouteKeys.length; + + if (numberOfSuperWideRoutes > 0) { expandedRHPProgress.setValue(2); - if (wideRHPRouteKeys.length > 0) { - innerRHPProgress.setValue(1); - } else { - innerRHPProgress.setValue(0); - } - } else if (wideRHPRouteKeys.length > 0) { + innerRHPProgress.setValue(numberOfWideRoutes > 0 ? 1 : 0); + } else if (numberOfWideRoutes > 0) { expandedRHPProgress.setValue(1); + innerRHPProgress.setValue(0); } else { expandedRHPProgress.setValue(0); innerRHPProgress.setValue(0); From bcbf94c2897fea9e9330d5e8147e31aa567c8a47 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Tue, 18 Nov 2025 12:19:19 +0100 Subject: [PATCH 43/64] Fix animation when closing single rhp displayed on swrhp --- .../AppNavigator/ModalStackNavigators/index.tsx | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index d57623711089..c5750afa29c9 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -133,15 +133,10 @@ function createModalStackNavigator(screens: Scr ); const isRHPDisplayedOnWideRHP = useMemo( - () => - !isSmallScreenWidth && - !isWideRHPFocused && - !isWideRHPClosing && - !isFocused && - shouldRenderSecondaryOverlay && - (isSuperWideRHPRouteName(route.name) || isWideRHPRouteName(route.name)), - [isFocused, isSmallScreenWidth, isWideRHPClosing, isWideRHPFocused, route.name, shouldRenderSecondaryOverlay], + () => !isSmallScreenWidth && !isWideRHPFocused && !isWideRHPClosing && shouldRenderSecondaryOverlay && (isSuperWideRHPRouteName(route.name) || isWideRHPRouteName(route.name)), + [isSmallScreenWidth, isWideRHPClosing, isWideRHPFocused, route.name, shouldRenderSecondaryOverlay], ); + const isWideRHPDisplayedOnSuperWideRHP = useMemo( () => !isSmallScreenWidth && !isFocused && !!isWideRHPFocused && shouldRenderSecondaryOverlay && isSuperWideRHPRouteName(route.name), [isFocused, isSmallScreenWidth, isWideRHPFocused, route.name, shouldRenderSecondaryOverlay], From 69a2daaf57c518a55ae89eb367edbfca4a683588 Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Tue, 18 Nov 2025 13:21:31 +0100 Subject: [PATCH 44/64] fixed back button and clicking to parent report when swrhp is already opened --- src/components/ParentNavigationSubtitle.tsx | 31 ++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/components/ParentNavigationSubtitle.tsx b/src/components/ParentNavigationSubtitle.tsx index 5892e9c11d30..7eb4de5a8dac 100644 --- a/src/components/ParentNavigationSubtitle.tsx +++ b/src/components/ParentNavigationSubtitle.tsx @@ -82,7 +82,20 @@ function ParentNavigationSubtitle({ const isReportArchived = useReportIsArchived(report?.reportID); const canUserPerformWriteAction = canUserPerformWriteActionReportUtils(report, isReportArchived); const isReportInRHP = currentRoute.name === SCREENS.SEARCH.REPORT_RHP; - const currentFullScreenRoute = useRootNavigationState((state) => state?.routes?.findLast((route) => isFullScreenName(route.name))); + const {currentFullScreenRoute, currentFocusedNavigator} = useRootNavigationState((state) => { + const FullScreenRoute = state?.routes?.findLast((route) => isFullScreenName(route.name)); + + const FocusedNavigator = !state?.routes + ? undefined + : state.routes.findLast((route) => { + return route.state?.routes && route.state.routes.length > 0; + }); + + return { + currentFullScreenRoute: FullScreenRoute, + currentFocusedNavigator: FocusedNavigator, + }; + }); // We should not display the parent navigation subtitle if the user does not have access to the parent chat (the reportName is empty in this case) if (!reportName) { @@ -106,6 +119,22 @@ function ParentNavigationSubtitle({ } } + // Dismiss wide RHP and go back to already opened super wide RHP if the parent report is already opened there + if (currentFocusedNavigator?.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR && currentFocusedNavigator.state?.index) { + const currentReportIndex = currentFocusedNavigator.state.index; + const previousRoute = currentFocusedNavigator.state.routes[currentReportIndex - 1]; + + if (previousRoute?.name === SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT) { + const lastPreviousRoute = previousRoute.state?.routes.at(-1); + const moneyRequestReportID = (lastPreviousRoute?.params as SearchMoneyRequestReportParamList[typeof SCREENS.SEARCH.MONEY_REQUEST_REPORT])?.reportID; + + if (moneyRequestReportID === parentReportID && lastPreviousRoute?.name === SCREENS.SEARCH.MONEY_REQUEST_REPORT) { + Navigation.goBack(); + return; + } + } + } + Navigation.navigate(ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID: parentReportID})); return; } From a0ff628e17e94728ffc8b7c6241b62810f47374b Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Tue, 18 Nov 2025 14:05:53 +0100 Subject: [PATCH 45/64] Adjust shouldShowSecondaryOverlay --- src/components/WideRHPContextProvider/index.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index f2efdc412aa6..a6d64e66f146 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -234,7 +234,19 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const shouldShowSecondaryOverlay = useRootNavigationState((state) => { const isRHPLastRootRoute = state?.routes.at(-1)?.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR; - if (!isRHPLastRootRoute) { + if (!isRHPLastRootRoute || !state) { + return false; + } + + const focusedRoute = findFocusedRoute(state); + + // Shouldn't ever happen but for type safety + if (!focusedRoute?.key) { + return false; + } + + // For this screen the secondary overlay should never be shown, it is always displayed as 1 RHP in the order + if (isSuperWideRHPRouteName(focusedRoute.name)) { return false; } From 2ba0f03175a12c8b57896b3792642e5c34442851 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Tue, 18 Nov 2025 15:35:53 +0100 Subject: [PATCH 46/64] Adjust shouldShowTertiaryOverlay --- src/components/WideRHPContextProvider/index.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index a6d64e66f146..d0123add09a0 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -265,6 +265,16 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { return false; } + const rhpState = state?.routes?.at(-1); + + const lastSuperWideRHPIndex = rhpState?.state?.routes?.findLastIndex((route) => SUPER_WIDE_RIGHT_MODALS.has(route.name)) ?? -1; + + const lastWideRHPIndex = rhpState?.state?.routes?.findLastIndex((route) => route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT) ?? -1; + + if (lastSuperWideRHPIndex > lastWideRHPIndex) { + return false; + } + const isSuperWideRHPBelow = getIsSuperWideRHPBelowFocusedScreen(state); const isWideRHPBelow = getIsWideRHPBelowFocusedScreen(state); return isSuperWideRHPBelow && isWideRHPBelow; @@ -331,7 +341,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { if (!rootState) { return; } - + console.log('dismiss 1', isWideRHPFocused); const rhpState = rootState.routes.findLast((route) => route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR)?.state; if (!rhpState) { @@ -362,7 +372,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { if (!rootState) { return; } - + console.log('dismiss 2'); const rhpStateKey = rootState.routes.findLast((route) => route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR)?.state?.key; if (!rhpStateKey) { From 30471d06a1437a26b528cd90e6518cc570964516 Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Tue, 18 Nov 2025 16:05:32 +0100 Subject: [PATCH 47/64] fixed back button swrhp --- .../MoneyRequestReportView/MoneyRequestReportView.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx index 836f1a11e43d..3b3d911431c5 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx @@ -61,6 +61,16 @@ function goBackFromSearchMoneyRequest() { const rootState = navigationRef.getRootState(); const lastRoute = rootState.routes.at(-1); + if (!lastRoute) { + Log.hmmm('[goBackFromSearchMoneyRequest()] No last route found in root state.'); + return; + } + + if (lastRoute?.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR) { + Navigation.goBack(); + return; + } + if (lastRoute?.name !== NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR) { Log.hmmm('[goBackFromSearchMoneyRequest()] goBackFromSearchMoneyRequest was called from a different navigator than SearchFullscreenNavigator.'); return; From f047bc8e128bddd406ed7907dd5484b527c7b86b Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Tue, 18 Nov 2025 16:32:51 +0100 Subject: [PATCH 48/64] Optimize methods in WideRHPContextProvider --- .../WideRHPContextProvider/index.tsx | 54 ++++++++++++------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index d0123add09a0..81ae0ba5c5d4 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -185,7 +185,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { }, [focusedRouteKey, wideRHPRouteKeys]); const getIsSuperWideRHPBelowFocusedScreen = useCallback( - (state: NavigationState | undefined) => { + (state: NavigationState | undefined, lastVisibleRouteKey: string | undefined) => { if (!state) { return false; } @@ -197,8 +197,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { return false; } - const currentLastVisibleRHPRouteKey = getLastVisibleRHPRouteKey(state); - const currentSuperWideRHPRouteKeys = getCurrentWideRHPKeys(allSuperWideRHPRouteKeys, currentLastVisibleRHPRouteKey); + const currentSuperWideRHPRouteKeys = getCurrentWideRHPKeys(allSuperWideRHPRouteKeys, lastVisibleRouteKey); const isFocusedRouteSuperWide = isSuperWideRHPRouteName(focusedRoute.name); return currentSuperWideRHPRouteKeys.length > 0 && !currentSuperWideRHPRouteKeys.includes(focusedRoute.key) && !isFocusedRouteSuperWide; @@ -207,7 +206,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { ); const getIsWideRHPBelowFocusedScreen = useCallback( - (state: NavigationState | undefined) => { + (state: NavigationState | undefined, lastVisibleRouteKey: string | undefined) => { if (!state) { return false; } @@ -219,8 +218,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { return false; } - const currentLastVisibleRHPRouteKey = getLastVisibleRHPRouteKey(state); - const currentWideRHPRouteKeys = getCurrentWideRHPKeys(allWideRHPRouteKeys, currentLastVisibleRHPRouteKey); + const currentWideRHPRouteKeys = getCurrentWideRHPKeys(allWideRHPRouteKeys, lastVisibleRouteKey); const isFocusedRouteWide = focusedRoute.name === SCREENS.SEARCH.REPORT_RHP; return currentWideRHPRouteKeys.length > 0 && !currentWideRHPRouteKeys.includes(focusedRoute.key) && !isFocusedRouteWide; @@ -250,9 +248,16 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { return false; } - const isSuperWideRHPBelow = getIsSuperWideRHPBelowFocusedScreen(state); - const isWideRHPBelow = getIsWideRHPBelowFocusedScreen(state); - return isSuperWideRHPBelow || isWideRHPBelow; + const currentLastVisibleRHPRouteKey = getLastVisibleRHPRouteKey(state); + const isWideRHPBelow = getIsWideRHPBelowFocusedScreen(state, currentLastVisibleRHPRouteKey); + + if (isWideRHPBelow) { + return true; + } + + const isSuperWideRHPBelow = getIsSuperWideRHPBelowFocusedScreen(state, currentLastVisibleRHPRouteKey); + + return isSuperWideRHPBelow; }); /** @@ -265,19 +270,32 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { return false; } - const rhpState = state?.routes?.at(-1); + const rhpState = state?.routes?.at(-1)?.state; + + // Shouldn't ever happen but for type safety + if (!rhpState?.key) { + return false; + } + + const lastSuperWideRHPIndex = rhpState?.routes?.findLastIndex((route) => SUPER_WIDE_RIGHT_MODALS.has(route.name)) ?? -1; + + const isSuperWideRHPDirectlyBelowFocusedScreen = lastSuperWideRHPIndex === rhpState.routes.length - 2; + + if (isSuperWideRHPDirectlyBelowFocusedScreen) { + return false; + } - const lastSuperWideRHPIndex = rhpState?.state?.routes?.findLastIndex((route) => SUPER_WIDE_RIGHT_MODALS.has(route.name)) ?? -1; + const currentLastVisibleRHPRouteKey = getLastVisibleRHPRouteKey(state); - const lastWideRHPIndex = rhpState?.state?.routes?.findLastIndex((route) => route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT) ?? -1; + const isWideRHPBelow = getIsWideRHPBelowFocusedScreen(state, currentLastVisibleRHPRouteKey); - if (lastSuperWideRHPIndex > lastWideRHPIndex) { + if (!isWideRHPBelow) { return false; } - const isSuperWideRHPBelow = getIsSuperWideRHPBelowFocusedScreen(state); - const isWideRHPBelow = getIsWideRHPBelowFocusedScreen(state); - return isSuperWideRHPBelow && isWideRHPBelow; + const isSuperWideRHPBelow = getIsSuperWideRHPBelowFocusedScreen(state, currentLastVisibleRHPRouteKey); + + return isSuperWideRHPBelow; }); /** @@ -341,7 +359,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { if (!rootState) { return; } - console.log('dismiss 1', isWideRHPFocused); + const rhpState = rootState.routes.findLast((route) => route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR)?.state; if (!rhpState) { @@ -372,7 +390,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { if (!rootState) { return; } - console.log('dismiss 2'); + const rhpStateKey = rootState.routes.findLast((route) => route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR)?.state?.key; if (!rhpStateKey) { From 6f35792d9eadd484ac757a61970b672216213d26 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Tue, 18 Nov 2025 16:42:36 +0100 Subject: [PATCH 49/64] Fix text formatting --- .../Navigation/AppNavigator/useRootNavigatorScreenOptions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts b/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts index 69248b5b2e59..22c18b2fc6cd 100644 --- a/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts +++ b/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts @@ -67,7 +67,7 @@ const useRootNavigatorScreenOptions = () => { // 0 - Single RHP, y = 1 // 1 - Wide RHP, y = receiptPaneWidth / sidebarWidth + 1 // 2 - Super Wide RHP, y = superWideRHPWidth / sidebarWidth - // For the given values, after multiplying by sidebarWidth inside useModalCardStyleInterpolator, the correct widths ​​are obtained + // For the given values, after multiplying by sidebarWidth inside useModalCardStyleInterpolator, the correct widths are obtained. outputRangeMultiplier: isSmallScreenWidth ? undefined : Animated.add( From b83a8b25bba487c84d477c5e32ed5fbe5dff263e Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Tue, 18 Nov 2025 19:42:56 +0100 Subject: [PATCH 50/64] Add SCREENS.RIGHT_MODAL.SEARCH_REPORT_ACTIONS --- src/SCREENS.ts | 1 + .../ModalStackNavigators/index.tsx | 11 +++++++++-- .../Navigators/RightModalNavigator.tsx | 4 ++++ src/libs/Navigation/linkingConfig/config.ts | 6 +++++- src/libs/Navigation/types.ts | 19 ++++++++++++------- src/pages/Search/SearchHoldReasonPage.tsx | 6 +++--- ...rchMoneyRequestReportVerifyAccountPage.tsx | 4 ++-- .../Search/SearchReportVerifyAccountPage.tsx | 4 ++-- src/pages/iou/HoldReasonPage.tsx | 4 ++-- src/pages/iou/RejectReasonPage.tsx | 4 ++-- 10 files changed, 42 insertions(+), 21 deletions(-) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index be7a1dfb5dd1..dcc369f32e80 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -244,6 +244,7 @@ const SCREENS = { TRANSACTION_DUPLICATE: 'TransactionDuplicate', TRAVEL: 'Travel', SEARCH_REPORT: 'SearchReport', + SEARCH_REPORT_ACTIONS: 'SearchReportActions', SEARCH_MONEY_REQUEST_REPORT: 'SearchMoneyRequestReport', SEARCH_ADVANCED_FILTERS: 'SearchAdvancedFilters', SEARCH_SAVED_SEARCH: 'SearchSavedSearch', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index c5750afa29c9..6e121f45a251 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -45,6 +45,7 @@ import type { ScheduleCallParamList, SearchAdvancedFiltersParamList, SearchMoneyRequestReportParamList, + SearchReportActionsParamList, SearchReportParamList, SearchSavedSearchParamList, SettingsNavigatorParamList, @@ -892,8 +893,7 @@ const MergeTransactionStackNavigator = createModalStackNavigator require('../../../../pages/TransactionMerge/ConfirmationPage').default, }); -const SearchReportModalStackNavigator = createModalStackNavigator({ - [SCREENS.SEARCH.REPORT_RHP]: () => require('../../../../pages/home/ReportScreen').default, +const SearchReportActionsModalStackNavigator = createModalStackNavigator({ [SCREENS.SEARCH.ROOT_VERIFY_ACCOUNT]: () => require('../../../../pages/Search/SearchRootVerifyAccountPage').default, [SCREENS.SEARCH.MONEY_REQUEST_REPORT_VERIFY_ACCOUNT]: () => require('../../../../pages/Search/SearchMoneyRequestReportVerifyAccountPage').default, [SCREENS.SEARCH.MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS]: () => require('../../../../pages/Search/SearchHoldReasonPage').default, @@ -901,6 +901,12 @@ const SearchReportModalStackNavigator = createModalStackNavigator require('../../../../pages/Search/SearchTransactionsChangeReport').default, }); +// This navigator is reserved for the screen that can be displayed as Wide RHP, other screens should not be added here. +const SearchReportModalStackNavigator = createModalStackNavigator({ + [SCREENS.SEARCH.REPORT_RHP]: () => require('../../../../pages/home/ReportScreen').default, +}); + +// // This navigator is reserved for the screen that can be displayed as Super Wide RHP, other screens should not be added here. const SearchMoneyRequestReportModalStackNavigator = createModalStackNavigator({ [SCREENS.SEARCH.MONEY_REQUEST_REPORT]: () => require('../../../../pages/Search/SearchMoneyRequestReportPage').default, }); @@ -1047,4 +1053,5 @@ export { WorkspacesDomainModalStackNavigator, SearchMoneyRequestReportModalStackNavigator, ExpenseReportModalStackNavigator, + SearchReportActionsModalStackNavigator, }; diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index 4afc5ff99a04..4c7b3630f434 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -276,6 +276,10 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { }, }} /> + ['config'] = { }, [SCREENS.RIGHT_MODAL.SEARCH_REPORT]: { screens: { - [SCREENS.SEARCH.ROOT_VERIFY_ACCOUNT]: ROUTES.SEARCH_ROOT_VERIFY_ACCOUNT, [SCREENS.SEARCH.REPORT_RHP]: ROUTES.SEARCH_REPORT.route, + }, + }, + [SCREENS.RIGHT_MODAL.SEARCH_REPORT_ACTIONS]: { + screens: { + [SCREENS.SEARCH.ROOT_VERIFY_ACCOUNT]: ROUTES.SEARCH_ROOT_VERIFY_ACCOUNT, [SCREENS.SEARCH.MONEY_REQUEST_REPORT_VERIFY_ACCOUNT]: ROUTES.SEARCH_MONEY_REQUEST_REPORT_VERIFY_ACCOUNT.route, [SCREENS.SEARCH.MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS]: ROUTES.SEARCH_MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS.route, [SCREENS.SEARCH.TRANSACTION_HOLD_REASON_RHP]: ROUTES.TRANSACTION_HOLD_REASON_RHP, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 87533f1711e6..cc13cac05951 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -2109,6 +2109,7 @@ type RightModalNavigatorParamList = { [SCREENS.RIGHT_MODAL.TRANSACTION_DUPLICATE]: NavigatorScreenParams; [SCREENS.RIGHT_MODAL.TRAVEL]: NavigatorScreenParams; [SCREENS.RIGHT_MODAL.SEARCH_REPORT]: NavigatorScreenParams; + [SCREENS.RIGHT_MODAL.SEARCH_REPORT_ACTIONS]: NavigatorScreenParams; [SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT]: NavigatorScreenParams; [SCREENS.RIGHT_MODAL.RESTRICTED_ACTION]: NavigatorScreenParams; [SCREENS.RIGHT_MODAL.SEARCH_ADVANCED_FILTERS]: NavigatorScreenParams; @@ -2586,13 +2587,7 @@ type AuthScreensParamList = SharedScreensParamList & [NAVIGATORS.TEST_TOOLS_MODAL_NAVIGATOR]: NavigatorScreenParams; }; -type SearchReportParamList = { - [SCREENS.SEARCH.REPORT_RHP]: { - reportID: string; - reportActionID?: string; - // eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md - backTo?: Routes; - }; +type SearchReportActionsParamList = { [SCREENS.SEARCH.REPORT_VERIFY_ACCOUNT]: { reportID: string; }; @@ -2622,6 +2617,15 @@ type SearchReportParamList = { }; }; +type SearchReportParamList = { + [SCREENS.SEARCH.REPORT_RHP]: { + reportID: string; + reportActionID?: string; + // eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md + backTo?: Routes; + }; +}; + type SearchMoneyRequestReportParamList = { [SCREENS.SEARCH.MONEY_REQUEST_REPORT]: { reportID: string; @@ -2862,4 +2866,5 @@ export type { WorkspacesDomainModalNavigatorParamList, DomainSplitNavigatorParamList, DomainScreenName, + SearchReportActionsParamList, }; diff --git a/src/pages/Search/SearchHoldReasonPage.tsx b/src/pages/Search/SearchHoldReasonPage.tsx index 50abf63ab9ed..ed6816f059fd 100644 --- a/src/pages/Search/SearchHoldReasonPage.tsx +++ b/src/pages/Search/SearchHoldReasonPage.tsx @@ -8,7 +8,7 @@ import {holdMoneyRequestOnSearch} from '@libs/actions/Search'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import {getFieldRequiredErrors} from '@libs/ValidationUtils'; -import type {SearchReportParamList} from '@navigation/types'; +import type {SearchReportActionsParamList} from '@navigation/types'; import HoldReasonFormView from '@pages/iou/HoldReasonFormView'; import {putTransactionsOnHold} from '@userActions/IOU'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -16,8 +16,8 @@ import SCREENS from '@src/SCREENS'; import INPUT_IDS from '@src/types/form/MoneyRequestHoldReasonForm'; type SearchHoldReasonPageProps = - | PlatformStackScreenProps - | PlatformStackScreenProps; + | PlatformStackScreenProps + | PlatformStackScreenProps; function SearchHoldReasonPage({route}: SearchHoldReasonPageProps) { const {translate} = useLocalize(); diff --git a/src/pages/Search/SearchMoneyRequestReportVerifyAccountPage.tsx b/src/pages/Search/SearchMoneyRequestReportVerifyAccountPage.tsx index 241b04324f90..fd82f44685da 100644 --- a/src/pages/Search/SearchMoneyRequestReportVerifyAccountPage.tsx +++ b/src/pages/Search/SearchMoneyRequestReportVerifyAccountPage.tsx @@ -1,11 +1,11 @@ import React from 'react'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; -import type {SearchReportParamList} from '@libs/Navigation/types'; +import type {SearchReportActionsParamList} from '@libs/Navigation/types'; import VerifyAccountPageBase from '@pages/settings/VerifyAccountPageBase'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; -type SearchMoneyRequestReportVerifyAccountPageProps = PlatformStackScreenProps; +type SearchMoneyRequestReportVerifyAccountPageProps = PlatformStackScreenProps; function SearchMoneyRequestReportVerifyAccountPage({route}: SearchMoneyRequestReportVerifyAccountPageProps) { return ; diff --git a/src/pages/Search/SearchReportVerifyAccountPage.tsx b/src/pages/Search/SearchReportVerifyAccountPage.tsx index 820f674dc3b5..94069384cf3c 100644 --- a/src/pages/Search/SearchReportVerifyAccountPage.tsx +++ b/src/pages/Search/SearchReportVerifyAccountPage.tsx @@ -1,11 +1,11 @@ import React from 'react'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; -import type {SearchReportParamList} from '@libs/Navigation/types'; +import type {SearchReportActionsParamList} from '@libs/Navigation/types'; import VerifyAccountPageBase from '@pages/settings/VerifyAccountPageBase'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; -type SearchReportVerifyAccountPageProps = PlatformStackScreenProps; +type SearchReportVerifyAccountPageProps = PlatformStackScreenProps; function SearchReportVerifyAccountPage({route}: SearchReportVerifyAccountPageProps) { return ; diff --git a/src/pages/iou/HoldReasonPage.tsx b/src/pages/iou/HoldReasonPage.tsx index 19194cabb19c..0441ec2a4eeb 100644 --- a/src/pages/iou/HoldReasonPage.tsx +++ b/src/pages/iou/HoldReasonPage.tsx @@ -6,7 +6,7 @@ import useOnyx from '@hooks/useOnyx'; import {addErrorMessage} from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; -import type {MoneyRequestNavigatorParamList, SearchReportParamList} from '@libs/Navigation/types'; +import type {MoneyRequestNavigatorParamList, SearchReportActionsParamList} from '@libs/Navigation/types'; import {getReportAction, isMoneyRequestAction} from '@libs/ReportActionsUtils'; import {canEditMoneyRequest, isReportInGroupPolicy} from '@libs/ReportUtils'; import {getFieldRequiredErrors} from '@libs/ValidationUtils'; @@ -19,7 +19,7 @@ import HoldReasonFormView from './HoldReasonFormView'; type HoldReasonPageProps = | PlatformStackScreenProps - | PlatformStackScreenProps; + | PlatformStackScreenProps; function HoldReasonPage({route}: HoldReasonPageProps) { const {translate} = useLocalize(); diff --git a/src/pages/iou/RejectReasonPage.tsx b/src/pages/iou/RejectReasonPage.tsx index 62edf7b5ca96..86ee77363724 100644 --- a/src/pages/iou/RejectReasonPage.tsx +++ b/src/pages/iou/RejectReasonPage.tsx @@ -4,7 +4,7 @@ import {useSearchContext} from '@components/Search/SearchContext'; import useLocalize from '@hooks/useLocalize'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; -import type {MoneyRequestNavigatorParamList, SearchReportParamList} from '@libs/Navigation/types'; +import type {MoneyRequestNavigatorParamList, SearchReportActionsParamList} from '@libs/Navigation/types'; import {getFieldRequiredErrors} from '@libs/ValidationUtils'; import {clearErrorFields, clearErrors} from '@userActions/FormActions'; import {rejectMoneyRequest} from '@userActions/IOU'; @@ -15,7 +15,7 @@ import RejectReasonFormView from './RejectReasonFormView'; type RejectReasonPageProps = | PlatformStackScreenProps - | PlatformStackScreenProps; + | PlatformStackScreenProps; function RejectReasonPage({route}: RejectReasonPageProps) { const {translate} = useLocalize(); From eddc2e9ace17bd76ddc41c3e054fc059e0a5ecd2 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Wed, 19 Nov 2025 10:37:08 +0100 Subject: [PATCH 51/64] Add markReportIDAsMultiTransactionExpense --- src/components/Search/index.tsx | 7 +++ .../WideRHPContextProvider/default.ts | 2 + .../WideRHPContextProvider/index.tsx | 49 ++++++++++++++----- .../WideRHPContextProvider/types.ts | 6 +++ 4 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 8cc8aa4d2158..bd616e240399 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -260,6 +260,8 @@ function Search({ const {accountID, email} = useCurrentUserPersonalDetails(); const [isActionLoadingSet = new Set()] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}`, {canBeMissing: true, selector: isActionLoadingSetSelector}); + const {markReportIDAsMultiTransactionExpense} = useContext(WideRHPContext); + // Filter violations based on user visibility const filteredViolations = useMemo(() => { if (!violations || !searchResults?.data) { @@ -708,6 +710,11 @@ function Search({ setOptimisticDataForTransactionThreadPreview(firstTransaction, transactionPreviewData); } } + + if (item.transactions.length > 1) { + markReportIDAsMultiTransactionExpense(reportID); + } + requestAnimationFrame(() => Navigation.navigate(ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID, backTo}))); return; } diff --git a/src/components/WideRHPContextProvider/default.ts b/src/components/WideRHPContextProvider/default.ts index d71e0e6b7f47..f61fed52d879 100644 --- a/src/components/WideRHPContextProvider/default.ts +++ b/src/components/WideRHPContextProvider/default.ts @@ -6,7 +6,9 @@ const defaultWideRHPContextValue: WideRHPContextType = { showWideRHPVersion: () => {}, cleanWideRHPRouteKey: () => {}, markReportIDAsExpense: () => {}, + markReportIDAsMultiTransactionExpense: () => {}, isReportIDMarkedAsExpense: () => false, + isReportIDMarkedAsMultiTransactionExpense: () => false, dismissToFirstRHP: () => {}, dismissToSecondRHP: () => {}, isWideRHPClosing: false, diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 81ae0ba5c5d4..0f3423d40869 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -170,6 +170,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const [shouldRenderSecondaryOverlay, setShouldRenderSecondaryOverlay] = useState(false); const [shouldRenderTertiaryOverlay, setShouldRenderTertiaryOverlay] = useState(false); const [expenseReportIDs, setExpenseReportIDs] = useState>(new Set()); + const [multiTransactionExpenseReportIDs, setMultiTransactionExpenseReportIDs] = useState>(new Set()); const [isWideRHPClosing, setIsWideRHPClosing] = useState(false); const focusedRouteKey = useRootNavigationState((state) => (state ? findFocusedRoute(state)?.key : undefined)); const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {selector: expenseReportSelector, canBeMissing: true}); @@ -256,7 +257,6 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { } const isSuperWideRHPBelow = getIsSuperWideRHPBelowFocusedScreen(state, currentLastVisibleRHPRouteKey); - return isSuperWideRHPBelow; }); @@ -278,7 +278,6 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { } const lastSuperWideRHPIndex = rhpState?.routes?.findLastIndex((route) => SUPER_WIDE_RIGHT_MODALS.has(route.name)) ?? -1; - const isSuperWideRHPDirectlyBelowFocusedScreen = lastSuperWideRHPIndex === rhpState.routes.length - 2; if (isSuperWideRHPDirectlyBelowFocusedScreen) { @@ -286,7 +285,6 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { } const currentLastVisibleRHPRouteKey = getLastVisibleRHPRouteKey(state); - const isWideRHPBelow = getIsWideRHPBelowFocusedScreen(state, currentLastVisibleRHPRouteKey); if (!isWideRHPBelow) { @@ -294,7 +292,6 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { } const isSuperWideRHPBelow = getIsSuperWideRHPBelowFocusedScreen(state, currentLastVisibleRHPRouteKey); - return isSuperWideRHPBelow; }); @@ -436,6 +433,31 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { [expenseReportIDs], ); + /** + * Marks a report ID as a multi-transaction expense report, adding it to the expense reports set. + * This enables optimistic super wide RHP display for expense reports. + * It helps us open expense as super wide, before it fully loads. + */ + const markReportIDAsMultiTransactionExpense = useCallback((reportID: string) => { + setMultiTransactionExpenseReportIDs((prev) => { + const newSet = new Set(prev); + newSet.add(reportID); + return newSet; + }); + }, []); + + /** + * Checks if a report ID is marked as a multi-transaction expense report. + * Used to determine if super wide RHP should be displayed optimistically. + * It helps us open expense as super wide, before it fully loads. + */ + const isReportIDMarkedAsMultiTransactionExpense = useCallback( + (reportID: string) => { + return multiTransactionExpenseReportIDs.has(reportID); + }, + [multiTransactionExpenseReportIDs], + ); + /** * Effect that shows/hides the expanded RHP progress based on the number of wide RHP routes. */ @@ -539,7 +561,9 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { dismissToFirstRHP, dismissToSecondRHP, markReportIDAsExpense, + markReportIDAsMultiTransactionExpense, isReportIDMarkedAsExpense, + isReportIDMarkedAsMultiTransactionExpense, isWideRHPFocused, isWideRHPClosing, setIsWideRHPClosing, @@ -552,13 +576,14 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { cleanWideRHPRouteKey, shouldRenderSecondaryOverlay, shouldRenderTertiaryOverlay, + dismissToFirstRHP, + dismissToSecondRHP, markReportIDAsExpense, + markReportIDAsMultiTransactionExpense, isReportIDMarkedAsExpense, + isReportIDMarkedAsMultiTransactionExpense, isWideRHPFocused, isWideRHPClosing, - setIsWideRHPClosing, - dismissToFirstRHP, - dismissToSecondRHP, ], ); @@ -612,7 +637,7 @@ function useShowSuperWideRHPVersion(condition: boolean) { const navigation = useNavigation(); const route = useRoute(); const reportID = route.params && 'reportID' in route.params && typeof route.params.reportID === 'string' ? route.params.reportID : ''; - const {showWideRHPVersion, showSuperWideRHPVersion, cleanWideRHPRouteKey, isReportIDMarkedAsExpense} = useContext(WideRHPContext); + const {showWideRHPVersion, showSuperWideRHPVersion, cleanWideRHPRouteKey, isReportIDMarkedAsExpense, isReportIDMarkedAsMultiTransactionExpense} = useContext(WideRHPContext); /** * Effect that sets up cleanup when the screen is about to be removed. @@ -633,12 +658,12 @@ function useShowSuperWideRHPVersion(condition: boolean) { */ useEffect(() => { // Check if we should show wide RHP based on condition OR if reportID is in optimistic set - if (!condition) { - showWideRHPVersion(route); + if (condition || (reportID && isReportIDMarkedAsMultiTransactionExpense(reportID))) { + showSuperWideRHPVersion(route); return; } - showSuperWideRHPVersion(route); - }, [condition, reportID, isReportIDMarkedAsExpense, route, showWideRHPVersion, showSuperWideRHPVersion]); + showWideRHPVersion(route); + }, [condition, reportID, isReportIDMarkedAsExpense, route, showWideRHPVersion, showSuperWideRHPVersion, isReportIDMarkedAsMultiTransactionExpense]); } WideRHPContextProvider.displayName = 'WideRHPContextProvider'; diff --git a/src/components/WideRHPContextProvider/types.ts b/src/components/WideRHPContextProvider/types.ts index 37cacdb5592e..a8bad2e837f3 100644 --- a/src/components/WideRHPContextProvider/types.ts +++ b/src/components/WideRHPContextProvider/types.ts @@ -25,9 +25,15 @@ type WideRHPContextType = { // Mark reportID as expense before condition check markReportIDAsExpense: (reportID: string) => void; + // Mark reportID as multi-transaction expense before condition check + markReportIDAsMultiTransactionExpense: (reportID: string) => void; + // Check if reportID is marked as expense isReportIDMarkedAsExpense: (reportID: string) => boolean; + // Check if reportID is marked as multi-transaction expense + isReportIDMarkedAsMultiTransactionExpense: (reportID: string) => boolean; + // Navigate to the first visible RHP dismissToFirstRHP: () => void; From a1b283be4a9515c637cbf1aaef7512e5a59f0aa5 Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Wed, 19 Nov 2025 12:12:15 +0100 Subject: [PATCH 52/64] changed styles to display superWideRHP in wide layout --- src/components/MoneyReportHeader.tsx | 2 +- .../MoneyRequestReportActionsList.tsx | 7 +++++-- .../MoneyRequestReportTransactionItem.tsx | 7 ++++--- .../MoneyRequestReportTransactionList.tsx | 4 +++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 2b1a6697a9a2..7795eb86269f 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -1411,7 +1411,7 @@ function MoneyReportHeader({ {isReportInSearch && ( )} diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx index ac77aa36ffec..947cfdece2be 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx @@ -5,7 +5,7 @@ import {isUserValidatedSelector} from '@selectors/Account'; import {accountIDSelector} from '@selectors/Session'; import {tierNameSelector} from '@selectors/UserWallet'; import isEmpty from 'lodash/isEmpty'; -import React, {useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react'; +import React, {useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react'; import type {NativeScrollEvent, NativeSyntheticEvent} from 'react-native'; import {DeviceEventEmitter, InteractionManager, View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; @@ -20,6 +20,7 @@ import {PressableWithFeedback} from '@components/Pressable'; import ScrollView from '@components/ScrollView'; import {useSearchContext} from '@components/Search/SearchContext'; import Text from '@components/Text'; +import {WideRHPContext} from '@components/WideRHPContextProvider'; import useLoadReportActions from '@hooks/useLoadReportActions'; import useLocalize from '@hooks/useLocalize'; import useMobileSelectionMode from '@hooks/useMobileSelectionMode'; @@ -165,7 +166,9 @@ function MoneyRequestReportActionsList({ const isReportArchived = useReportIsArchived(reportID); const canPerformWriteAction = canUserPerformWriteAction(report, isReportArchived); - const {shouldUseNarrowLayout} = useResponsiveLayout(); + const {shouldUseNarrowLayout: shouldUseNarrowLayoutByDefault, isSmallScreenWidth} = useResponsiveLayout(); + const {superWideRHPRouteKeys} = useContext(WideRHPContext); + const shouldUseNarrowLayout = shouldUseNarrowLayoutByDefault && (superWideRHPRouteKeys.length === 0 || isSmallScreenWidth); const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false}); const [offlineModalVisible, setOfflineModalVisible] = useState(false); diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionItem.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionItem.tsx index 2cb99cb3e834..4f4f95b7356c 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionItem.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionItem.tsx @@ -87,11 +87,12 @@ function MoneyRequestReportTransactionItem({ const {translate} = useLocalize(); const styles = useThemeStyles(); // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth - const {isSmallScreenWidth, isMediumScreenWidth, isLargeScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout(); + const {isSmallScreenWidth, isMediumScreenWidth, isLargeScreenWidth, shouldUseNarrowLayout: shouldUseNarrowLayoutByDefault} = useResponsiveLayout(); + const {superWideRHPRouteKeys} = useContext(WideRHPContext); + const shouldUseNarrowLayout = shouldUseNarrowLayoutByDefault && (superWideRHPRouteKeys.length === 0 || isSmallScreenWidth); const theme = useTheme(); const isPendingDelete = isTransactionPendingDelete(transaction); const pendingAction = getTransactionPendingAction(transaction); - const {superWideRHPRouteKeys} = useContext(WideRHPContext); const viewRef = useRef(null); @@ -156,7 +157,7 @@ function MoneyRequestReportTransactionItem({ columns={columns} areAllOptionalColumnsHidden={areAllOptionalColumnsHidden} isDisabled={isPendingDelete} - style={[styles.p3, isLargeScreenWidth && !superWideRHPRouteKeys.length && styles.pr0]} + style={[styles.p3, isLargeScreenWidth && styles.pr0]} onButtonPress={() => { handleOnPress(transaction.transactionID); }} diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx index 5deddd7c1d6b..8746d10a2151 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx @@ -161,7 +161,9 @@ function MoneyRequestReportTransactionList({ const StyleUtils = useStyleUtils(); const {translate, localeCompare} = useLocalize(); // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth - const {shouldUseNarrowLayout, isSmallScreenWidth, isMediumScreenWidth} = useResponsiveLayout(); + const {shouldUseNarrowLayout: shouldUseNarrowLayoutByDefault, isSmallScreenWidth, isMediumScreenWidth} = useResponsiveLayout(); + const {superWideRHPRouteKeys} = useContext(WideRHPContext); + const shouldUseNarrowLayout = shouldUseNarrowLayoutByDefault && (superWideRHPRouteKeys.length === 0 || isSmallScreenWidth); const {markReportIDAsExpense} = useContext(WideRHPContext); const [isModalVisible, setIsModalVisible] = useState(false); const [selectedTransactionID, setSelectedTransactionID] = useState(''); From 4de7f3e386e43169f72b1655cd566eb4cff243e7 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Wed, 19 Nov 2025 15:12:23 +0100 Subject: [PATCH 53/64] Adjust reading wide and super wide rhp keys --- .../WideRHPContextProvider/default.ts | 3 ++ .../WideRHPContextProvider/index.tsx | 31 +++++++++++++-- .../WideRHPContextProvider/types.ts | 9 +++++ .../Navigators/RightModalNavigator.tsx | 38 ++++++++++++++++++- 4 files changed, 75 insertions(+), 6 deletions(-) diff --git a/src/components/WideRHPContextProvider/default.ts b/src/components/WideRHPContextProvider/default.ts index f61fed52d879..bad5e313fbdd 100644 --- a/src/components/WideRHPContextProvider/default.ts +++ b/src/components/WideRHPContextProvider/default.ts @@ -17,6 +17,9 @@ const defaultWideRHPContextValue: WideRHPContextType = { shouldRenderTertiaryOverlay: false, superWideRHPRouteKeys: [], showSuperWideRHPVersion: () => {}, + syncWideRHPKeys: () => {}, + syncSuperWideRHPKeys: () => {}, + clearWideRHPKeys: () => {}, }; export default defaultWideRHPContextValue; diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 0f3423d40869..321babab91af 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -166,7 +166,9 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { // We have a separate containers for allWideRHPRouteKeys and wideRHPRouteKeys because we may have two or more RHPs on the stack. // For convenience and proper overlay logic wideRHPRouteKeys will show only the keys existing in the last RHP. const [allWideRHPRouteKeys, setAllWideRHPRouteKeys] = useState([]); + const [wideRHPRouteKeys, setWideRHPRouteKeys] = useState([]); const [allSuperWideRHPRouteKeys, setAllSuperWideRHPRouteKeys] = useState([]); + const [superWideRHPRouteKeys, setSuperWideRHPRouteKeys] = useState([]); const [shouldRenderSecondaryOverlay, setShouldRenderSecondaryOverlay] = useState(false); const [shouldRenderTertiaryOverlay, setShouldRenderTertiaryOverlay] = useState(false); const [expenseReportIDs, setExpenseReportIDs] = useState>(new Set()); @@ -175,11 +177,26 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { const focusedRouteKey = useRootNavigationState((state) => (state ? findFocusedRoute(state)?.key : undefined)); const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {selector: expenseReportSelector, canBeMissing: true}); - // Return undefined if RHP is not the last route - const lastVisibleRHPRouteKey = useRootNavigationState((state) => getLastVisibleRHPRouteKey(state)); + const syncWideRHPKeys = useCallback(() => { + setWideRHPRouteKeys(getCurrentWideRHPKeys(allWideRHPRouteKeys, getLastVisibleRHPRouteKey(navigationRef.getRootState()))); + }, [allWideRHPRouteKeys]); - const wideRHPRouteKeys = useMemo(() => getCurrentWideRHPKeys(allWideRHPRouteKeys, lastVisibleRHPRouteKey), [allWideRHPRouteKeys, lastVisibleRHPRouteKey]); - const superWideRHPRouteKeys = useMemo(() => getCurrentWideRHPKeys(allSuperWideRHPRouteKeys, lastVisibleRHPRouteKey), [allSuperWideRHPRouteKeys, lastVisibleRHPRouteKey]); + const syncSuperWideRHPKeys = useCallback(() => { + setSuperWideRHPRouteKeys(getCurrentWideRHPKeys(allSuperWideRHPRouteKeys, getLastVisibleRHPRouteKey(navigationRef.getRootState()))); + }, [allSuperWideRHPRouteKeys]); + + const clearWideRHPKeys = useCallback(() => { + setWideRHPRouteKeys([]); + setSuperWideRHPRouteKeys([]); + }, []); + + useEffect(() => { + syncWideRHPKeys(); + }, [allWideRHPRouteKeys, syncWideRHPKeys]); + + useEffect(() => { + syncSuperWideRHPKeys(); + }, [allSuperWideRHPRouteKeys, syncSuperWideRHPKeys]); const isWideRHPFocused = useMemo(() => { return !!focusedRouteKey && wideRHPRouteKeys.includes(focusedRouteKey); @@ -567,6 +584,9 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { isWideRHPFocused, isWideRHPClosing, setIsWideRHPClosing, + syncWideRHPKeys, + syncSuperWideRHPKeys, + clearWideRHPKeys, }), [ wideRHPRouteKeys, @@ -584,6 +604,9 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { isReportIDMarkedAsMultiTransactionExpense, isWideRHPFocused, isWideRHPClosing, + syncWideRHPKeys, + syncSuperWideRHPKeys, + clearWideRHPKeys, ], ); diff --git a/src/components/WideRHPContextProvider/types.ts b/src/components/WideRHPContextProvider/types.ts index a8bad2e837f3..c51eda9e816e 100644 --- a/src/components/WideRHPContextProvider/types.ts +++ b/src/components/WideRHPContextProvider/types.ts @@ -48,6 +48,15 @@ type WideRHPContextType = { // Mark that wide rhp is being closed setIsWideRHPClosing: (isClosing: boolean) => void; + + // Sync wide RHP keys with the visible RHP screens + syncWideRHPKeys: () => void; + + // Sync super wide RHP keys with the visible RHP screens + syncSuperWideRHPKeys: () => void; + + // Clear the arrays of wide and super wide rhp keys + clearWideRHPKeys: () => void; }; // eslint-disable-next-line import/prefer-default-export diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index 4c7b3630f434..c2310c7ac6f0 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -1,4 +1,5 @@ import type {NavigatorScreenParams} from '@react-navigation/native'; +import {useFocusEffect} from '@react-navigation/native'; import type {StackCardInterpolationProps} from '@react-navigation/stack'; import React, {useCallback, useContext, useMemo, useRef} from 'react'; // eslint-disable-next-line no-restricted-imports @@ -23,6 +24,7 @@ import hideKeyboardOnSwipe from '@libs/Navigation/AppNavigator/hideKeyboardOnSwi import * as ModalStackNavigators from '@libs/Navigation/AppNavigator/ModalStackNavigators'; import useModalCardStyleInterpolator from '@libs/Navigation/AppNavigator/useModalCardStyleInterpolator'; import useRHPScreenOptions from '@libs/Navigation/AppNavigator/useRHPScreenOptions'; +import {navigationRef} from '@libs/Navigation/Navigation'; import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {AuthScreensParamList, RightModalNavigatorParamList} from '@navigation/types'; @@ -45,7 +47,17 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { const {shouldUseNarrowLayout, isSmallScreenWidth} = useResponsiveLayout(); const isExecutingRef = useRef(false); const screenOptions = useRHPScreenOptions(); - const {shouldRenderSecondaryOverlay, isWideRHPFocused, shouldRenderTertiaryOverlay, isWideRHPClosing, dismissToFirstRHP, dismissToSecondRHP} = useContext(WideRHPContext); + const { + shouldRenderSecondaryOverlay, + isWideRHPFocused, + shouldRenderTertiaryOverlay, + isWideRHPClosing, + clearWideRHPKeys, + dismissToFirstRHP, + dismissToSecondRHP, + syncWideRHPKeys, + syncSuperWideRHPKeys, + } = useContext(WideRHPContext); const {windowWidth} = useWindowDimensions(); const modalCardStyleInterpolator = useModalCardStyleInterpolator(); const styles = useThemeStyles(); @@ -61,6 +73,8 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { } as const; }, [animatedWidth, shouldUseNarrowLayout]); + const overlayPositionLeft = useMemo(() => -1 * calculateSuperWideRHPWidth(windowWidth), [windowWidth]); + const screenListeners = useMemo( () => ({ blur: () => { @@ -93,10 +107,30 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { }, CONST.ANIMATED_TRANSITION); }, [navigation]); + useFocusEffect( + useCallback(() => { + syncWideRHPKeys(); + syncSuperWideRHPKeys(); + + return () => { + const isRhpClosed = !navigationRef?.getRootState()?.routes?.some((rootStateRoute) => rootStateRoute.key === route.key); + if (isRhpClosed) { + return; + } + clearWideRHPKeys(); + }; + }, [syncWideRHPKeys, syncSuperWideRHPKeys, clearWideRHPKeys, route.key]), + ); + return ( - {!shouldUseNarrowLayout && } + {!shouldUseNarrowLayout && ( + + )} {/* This one is to limit the outer Animated.View and allow the background to be pressable */} {/* Without it, the transparent half of the narrow format RHP card would cover the pressable part of the overlay */} From e1286e616ff722fd4e78698d366b7a090cd62ed2 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Wed, 19 Nov 2025 15:59:50 +0100 Subject: [PATCH 54/64] Fix showing not found page when deleting transactions --- src/pages/Search/SearchMoneyRequestReportPage.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pages/Search/SearchMoneyRequestReportPage.tsx b/src/pages/Search/SearchMoneyRequestReportPage.tsx index b5be92b65411..fd0f8226f4dc 100644 --- a/src/pages/Search/SearchMoneyRequestReportPage.tsx +++ b/src/pages/Search/SearchMoneyRequestReportPage.tsx @@ -1,5 +1,5 @@ import {PortalHost} from '@gorhom/portal'; -import React, {useEffect, useMemo, useRef, useState} from 'react'; +import React, {useContext, useEffect, useMemo, useRef, useState} from 'react'; import type {FlatList} from 'react-native'; import {View} from 'react-native'; import type {OnyxCollection} from 'react-native-onyx'; @@ -7,7 +7,7 @@ import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView import DragAndDropProvider from '@components/DragAndDrop/Provider'; import MoneyRequestReportView from '@components/MoneyRequestReportView/MoneyRequestReportView'; import ScreenWrapper from '@components/ScreenWrapper'; -import {useShowSuperWideRHPVersion} from '@components/WideRHPContextProvider'; +import {useShowSuperWideRHPVersion, WideRHPContext} from '@components/WideRHPContextProvider'; import useIsReportReadyToDisplay from '@hooks/useIsReportReadyToDisplay'; import useNetwork from '@hooks/useNetwork'; import useOnyx from '@hooks/useOnyx'; @@ -50,6 +50,7 @@ function SearchMoneyRequestReportPage({route}: SearchMoneyRequestPageProps) { const {shouldUseNarrowLayout} = useResponsiveLayout(); const styles = useThemeStyles(); const {isOffline} = useNetwork(); + const {superWideRHPRouteKeys} = useContext(WideRHPContext); const reportIDFromRoute = getNonEmptyStringOnyxID(route.params?.reportID); const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportIDFromRoute}`, {allowStaleData: true, canBeMissing: true}); @@ -101,6 +102,10 @@ function SearchMoneyRequestReportPage({route}: SearchMoneyRequestPageProps) { // eslint-disable-next-line rulesdir/no-negated-variables const shouldShowNotFoundPage = useMemo( (): boolean => { + if (superWideRHPRouteKeys.length > 0) { + return false; + } + if (isLoadingApp !== false) { return false; } From e09233c4f13546904c2593a5275b0c3621edd517 Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Wed, 19 Nov 2025 16:33:54 +0100 Subject: [PATCH 55/64] fixed adding expense and dismissing to the first wide/super wide rhp modal in stack --- .../WideRHPContextProvider/index.tsx | 2 ++ src/libs/Navigation/Navigation.ts | 20 +++++++++++++++++++ .../Navigation/helpers/isReportOpenInRHP.ts | 6 +++++- .../helpers/isReportOpenInSuperWideRHP.ts | 18 +++++++++++++++++ src/libs/actions/IOU.ts | 6 ++++++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/libs/Navigation/helpers/isReportOpenInSuperWideRHP.ts diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index 0f3423d40869..d17316cfdfde 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -685,4 +685,6 @@ export { animatedWideRHPWidth, innerRHPProgress, expandedRHPProgress, + WIDE_RIGHT_MODALS, + SUPER_WIDE_RIGHT_MODALS, }; diff --git a/src/libs/Navigation/Navigation.ts b/src/libs/Navigation/Navigation.ts index af7f5f826588..4ab6da65c099 100644 --- a/src/libs/Navigation/Navigation.ts +++ b/src/libs/Navigation/Navigation.ts @@ -604,6 +604,25 @@ const dismissModalWithReport = ({reportID, reportActionID, referrer, backTo}: Re }); }; +/** + * Returns to the first screen in the Right Hand Modal stack, dismissing all the others. + */ +const dismissToFirstRHP = () => { + const rootState = navigationRef.getRootState(); + if (!rootState) { + return; + } + + const rhpState = rootState.routes.findLast((route) => route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR)?.state; + + if (!rhpState) { + return; + } + + const routesToPop = rhpState.routes.length - 1; + navigationRef.dispatch({...StackActions.pop(routesToPop), target: rhpState.key}); +}; + /** * Returns to the first screen in the stack, dismissing all the others, only if the global variable shouldPopToSidebar is set to true. */ @@ -743,6 +762,7 @@ export default { onModalDismissedOnce, fireModalDismissed, isValidateLoginFlow, + dismissToFirstRHP, }; export {navigationRef}; diff --git a/src/libs/Navigation/helpers/isReportOpenInRHP.ts b/src/libs/Navigation/helpers/isReportOpenInRHP.ts index 51e8a95bb66b..542f852b1d4a 100644 --- a/src/libs/Navigation/helpers/isReportOpenInRHP.ts +++ b/src/libs/Navigation/helpers/isReportOpenInRHP.ts @@ -1,3 +1,4 @@ +import {WIDE_RIGHT_MODALS} from '@components/WideRHPContextProvider'; import type {NavigationState} from '@react-navigation/native'; import NAVIGATORS from '@src/NAVIGATORS'; import SCREENS from '@src/SCREENS'; @@ -11,7 +12,10 @@ const isReportOpenInRHP = (state: NavigationState | undefined): boolean => { if (params && 'screen' in params && typeof params.screen === 'string' && params.screen === SCREENS.RIGHT_MODAL.SEARCH_REPORT) { return true; } - return !!(lastRoute.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR && lastRoute.state?.routes?.some((route) => route?.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT)); + return !!( + lastRoute.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR && + lastRoute.state?.routes?.some((route) => WIDE_RIGHT_MODALS.has(route.name)) + ); }; export default isReportOpenInRHP; diff --git a/src/libs/Navigation/helpers/isReportOpenInSuperWideRHP.ts b/src/libs/Navigation/helpers/isReportOpenInSuperWideRHP.ts new file mode 100644 index 000000000000..368d4cf508bb --- /dev/null +++ b/src/libs/Navigation/helpers/isReportOpenInSuperWideRHP.ts @@ -0,0 +1,18 @@ +import type {NavigationState} from '@react-navigation/native'; +import {SUPER_WIDE_RIGHT_MODALS} from '@components/WideRHPContextProvider'; +import NAVIGATORS from '@src/NAVIGATORS'; +import SCREENS from '@src/SCREENS'; + +const isReportOpenInSuperWideRHP = (state: NavigationState | undefined): boolean => { + const lastRoute = state?.routes?.at(-1); + if (!lastRoute) { + return false; + } + const params = lastRoute.params; + if (params && 'screen' in params && typeof params.screen === 'string' && params.screen === SCREENS.RIGHT_MODAL.SEARCH_REPORT) { + return true; + } + return !!(lastRoute.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR && lastRoute.state?.routes?.some((route) => SUPER_WIDE_RIGHT_MODALS.has(route.name))); +}; + +export default isReportOpenInSuperWideRHP; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 0469c912fdb0..a55d691280a4 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -68,6 +68,7 @@ import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import * as Localize from '@libs/Localize'; import Log from '@libs/Log'; import isReportOpenInRHP from '@libs/Navigation/helpers/isReportOpenInRHP'; +import isReportOpenInSuperWideRHP from '@libs/Navigation/helpers/isReportOpenInSuperWideRHP'; import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute'; import Navigation, {navigationRef} from '@libs/Navigation/Navigation'; // TODO: Replace onyx.connect with useOnyx hook (https://github.com/Expensify/App/issues/66365) @@ -953,6 +954,11 @@ function dismissModalAndOpenReportInInboxTab(reportID?: string) { const rhpKey = rootState.routes.at(-1)?.state?.key; if (rhpKey) { const hasMultipleTransactions = Object.values(allTransactions).filter((transaction) => transaction?.reportID === reportID).length > 0; + // When a report is opened in the super wide RHP, we need to dismiss to the first RHP to show the same report with new expense. + if (isReportOpenInSuperWideRHP(rootState)) { + Navigation.dismissToFirstRHP(); + return; + } // 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. if (hasMultipleTransactions && reportID) { Navigation.dismissModal(); From 945caf16cef507ec1f912ca481628fc3834c9f5a Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Wed, 19 Nov 2025 16:51:26 +0100 Subject: [PATCH 56/64] added export constants also for mobile devices --- src/components/WideRHPContextProvider/index.native.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/WideRHPContextProvider/index.native.tsx b/src/components/WideRHPContextProvider/index.native.tsx index 7b59a15e740e..dfeae5ad06a7 100644 --- a/src/components/WideRHPContextProvider/index.native.tsx +++ b/src/components/WideRHPContextProvider/index.native.tsx @@ -3,6 +3,7 @@ import React, {createContext} from 'react'; // to interact with react-navigation components (e.g., CardContainer, interpolator), which also use Animated. // eslint-disable-next-line no-restricted-imports import {Animated} from 'react-native'; +import SCREENS from '@src/SCREENS'; import defaultWideRHPContextValue from './default'; import type {WideRHPContextType} from './types'; @@ -21,6 +22,10 @@ const innerRHPProgress = new Animated.Value(0); const WideRHPContext = createContext(defaultWideRHPContextValue); +const WIDE_RIGHT_MODALS = new Set([SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT, SCREENS.RIGHT_MODAL.EXPENSE_REPORT, SCREENS.RIGHT_MODAL.SEARCH_REPORT]); + +const SUPER_WIDE_RIGHT_MODALS = new Set([SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT, SCREENS.RIGHT_MODAL.EXPENSE_REPORT]); + function WideRHPContextProvider({children}: React.PropsWithChildren) { return {children}; } @@ -60,4 +65,6 @@ export { animatedWideRHPWidth, innerRHPProgress, expandedRHPProgress, + WIDE_RIGHT_MODALS, + SUPER_WIDE_RIGHT_MODALS, }; From 57c2cde97787146775a6ccf2ef8f891966d2a6a5 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Wed, 19 Nov 2025 16:56:18 +0100 Subject: [PATCH 57/64] Run prettier --- src/libs/Navigation/helpers/isReportOpenInRHP.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/libs/Navigation/helpers/isReportOpenInRHP.ts b/src/libs/Navigation/helpers/isReportOpenInRHP.ts index 542f852b1d4a..031cb4546c76 100644 --- a/src/libs/Navigation/helpers/isReportOpenInRHP.ts +++ b/src/libs/Navigation/helpers/isReportOpenInRHP.ts @@ -1,5 +1,5 @@ -import {WIDE_RIGHT_MODALS} from '@components/WideRHPContextProvider'; import type {NavigationState} from '@react-navigation/native'; +import {WIDE_RIGHT_MODALS} from '@components/WideRHPContextProvider'; import NAVIGATORS from '@src/NAVIGATORS'; import SCREENS from '@src/SCREENS'; @@ -12,10 +12,7 @@ const isReportOpenInRHP = (state: NavigationState | undefined): boolean => { if (params && 'screen' in params && typeof params.screen === 'string' && params.screen === SCREENS.RIGHT_MODAL.SEARCH_REPORT) { return true; } - return !!( - lastRoute.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR && - lastRoute.state?.routes?.some((route) => WIDE_RIGHT_MODALS.has(route.name)) - ); + return !!(lastRoute.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR && lastRoute.state?.routes?.some((route) => WIDE_RIGHT_MODALS.has(route.name))); }; export default isReportOpenInRHP; From 14c29dd2e384c4bcfa1939238e2c50b2dad08f35 Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Thu, 20 Nov 2025 10:28:55 +0100 Subject: [PATCH 58/64] eslint fix --- .../MoneyRequestReportView/MoneyRequestReportActionsList.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx index 947cfdece2be..ca58399a7fa9 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx @@ -166,6 +166,7 @@ function MoneyRequestReportActionsList({ const isReportArchived = useReportIsArchived(reportID); const canPerformWriteAction = canUserPerformWriteAction(report, isReportArchived); + // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth const {shouldUseNarrowLayout: shouldUseNarrowLayoutByDefault, isSmallScreenWidth} = useResponsiveLayout(); const {superWideRHPRouteKeys} = useContext(WideRHPContext); const shouldUseNarrowLayout = shouldUseNarrowLayoutByDefault && (superWideRHPRouteKeys.length === 0 || isSmallScreenWidth); From e9dbe5af395a6a932db6fed89b4acee685ae31b6 Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Thu, 20 Nov 2025 13:43:50 +0100 Subject: [PATCH 59/64] fixed confirm navigation for split and merge in report --- src/libs/Navigation/Navigation.ts | 5 +++++ src/libs/actions/IOU.ts | 2 +- src/pages/TransactionMerge/ConfirmationPage.tsx | 2 +- src/pages/iou/SplitExpensePage.tsx | 6 +++--- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/libs/Navigation/Navigation.ts b/src/libs/Navigation/Navigation.ts index 4ab6da65c099..66a482179bb3 100644 --- a/src/libs/Navigation/Navigation.ts +++ b/src/libs/Navigation/Navigation.ts @@ -620,6 +620,11 @@ const dismissToFirstRHP = () => { } const routesToPop = rhpState.routes.length - 1; + if (routesToPop <= 0) { + dismissModal(); + return; + } + navigationRef.dispatch({...StackActions.pop(routesToPop), target: rhpState.key}); }; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 823f0618c962..af2bb4b19adf 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -14320,7 +14320,7 @@ function updateSplitTransactionsFromSplitExpensesFlow(params: UpdateSplitTransac const transactionThreadReportScreen = Navigation.getReportRouteByID(transactionThreadReportID); if (isSearchPageTopmostFullScreenRoute || !transactionReport?.parentReportID) { - Navigation.dismissModal(); + Navigation.dismissToFirstRHP(); // After the modal is dismissed, remove the transaction thread report screen // to avoid navigating back to a report removed by the split transaction. diff --git a/src/pages/TransactionMerge/ConfirmationPage.tsx b/src/pages/TransactionMerge/ConfirmationPage.tsx index 0f6b2dee426d..98f23c6ad5be 100644 --- a/src/pages/TransactionMerge/ConfirmationPage.tsx +++ b/src/pages/TransactionMerge/ConfirmationPage.tsx @@ -92,7 +92,7 @@ function ConfirmationPage({route}: ConfirmationPageProps) { if (reportID !== targetTransaction.reportID && reportIDToDismiss) { Navigation.dismissModalWithReport({reportID: reportIDToDismiss}); } else { - Navigation.dismissModal(); + Navigation.dismissToFirstRHP(); } }, [targetTransaction, mergeTransaction, sourceTransaction, transactionID, targetTransactionThreadReportID, policy, policyTags, policyCategories]); diff --git a/src/pages/iou/SplitExpensePage.tsx b/src/pages/iou/SplitExpensePage.tsx index cc54b30e27a0..6902cd526695 100644 --- a/src/pages/iou/SplitExpensePage.tsx +++ b/src/pages/iou/SplitExpensePage.tsx @@ -134,12 +134,12 @@ function SplitExpensePage({route}: SplitExpensePageProps) { const splitExpenseWithoutID = {...splitExpenses.at(0), transactionID: ''}; // When we try to save one split during splits creation and if the data is identical to the original transaction we should close the split flow if (!childTransactions.length && deepEqual(splitFieldDataFromOriginalTransactionWithoutID, splitExpenseWithoutID)) { - Navigation.dismissModal(); + Navigation.dismissToFirstRHP(); return; } // When we try to save splits during editing splits and if the data is identical to the already created transactions we should close the split flow if (childTransactions.length && deepEqual(splitFieldDataFromChildTransactions, splitExpenses)) { - Navigation.dismissModal(); + Navigation.dismissToFirstRHP(); return; } // When we try to save one split during splits creation and if the data is not identical to the original transaction we should show the error @@ -167,7 +167,7 @@ function SplitExpensePage({route}: SplitExpensePageProps) { // When we try to save splits during editing splits and if the data is identical to the already created transactions we should close the split flow if (deepEqual(splitFieldDataFromChildTransactions, splitExpenses)) { - Navigation.dismissModal(); + Navigation.dismissToFirstRHP(); return; } From 980b84f23497c2175e9cbf36d8ccc9773ff5187b Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Thu, 20 Nov 2025 13:48:01 +0100 Subject: [PATCH 60/64] fix prettier --- src/libs/Navigation/Navigation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Navigation/Navigation.ts b/src/libs/Navigation/Navigation.ts index 66a482179bb3..47bbfa90b4d8 100644 --- a/src/libs/Navigation/Navigation.ts +++ b/src/libs/Navigation/Navigation.ts @@ -624,7 +624,7 @@ const dismissToFirstRHP = () => { dismissModal(); return; } - + navigationRef.dispatch({...StackActions.pop(routesToPop), target: rhpState.key}); }; From ade17a8f3ad45f52d2058fe8838845608cfb056a Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Thu, 20 Nov 2025 14:03:31 +0100 Subject: [PATCH 61/64] fix tests --- tests/actions/IOUTest.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index 40e47c068f97..43d42bf85ba9 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -120,6 +120,7 @@ const topMostReportID = '23423423'; jest.mock('@src/libs/Navigation/Navigation', () => ({ navigate: jest.fn(), dismissModal: jest.fn(), + dismissToFirstRHP: jest.fn(), dismissModalWithReport: jest.fn(), goBack: jest.fn(), getTopmostReportId: jest.fn(() => topMostReportID), From a1864bd4bc15a930c6f8d1ce0bbdac326055427c Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Thu, 20 Nov 2025 16:27:23 +0100 Subject: [PATCH 62/64] Remove SearchTransaction type usage from Search/index.tsx and IOU.ts --- src/components/Search/index.tsx | 5 ++--- src/libs/actions/IOU.ts | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 76f8afd48649..61650daf1645 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -65,11 +65,10 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import SCREENS from '@src/SCREENS'; import {isActionLoadingSetSelector} from '@src/selectors/ReportMetaData'; -import type {OutstandingReportsByPolicyIDDerivedValue} from '@src/types/onyx'; +import type {OutstandingReportsByPolicyIDDerivedValue, Transaction} from '@src/types/onyx'; import type Policy from '@src/types/onyx/Policy'; import type Report from '@src/types/onyx/Report'; import type SearchResults from '@src/types/onyx/SearchResults'; -import type {SearchTransaction} from '@src/types/onyx/SearchResults'; import type {TransactionViolation} from '@src/types/onyx/TransactionViolation'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import arraysEqual from '@src/utils/arraysEqual'; @@ -277,7 +276,7 @@ function Search({ const transactionKeys = Object.keys(searchResults.data).filter((key) => key.startsWith(ONYXKEYS.COLLECTION.TRANSACTION)); for (const key of transactionKeys) { - const transaction = searchResults.data[key as keyof typeof searchResults.data] as SearchTransaction; + const transaction = searchResults.data[key as keyof typeof searchResults.data] as Transaction; if (!transaction || typeof transaction !== 'object' || !('transactionID' in transaction) || !('reportID' in transaction)) { continue; } diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 865c72ebfa1d..48667d13a824 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -252,7 +252,6 @@ import type RecentlyUsedTags from '@src/types/onyx/RecentlyUsedTags'; import type {InvoiceReceiver, InvoiceReceiverType} from '@src/types/onyx/Report'; import type ReportAction from '@src/types/onyx/ReportAction'; import type {OnyxData} from '@src/types/onyx/Request'; -import type {SearchTransaction} from '@src/types/onyx/SearchResults'; import type {Comment, Receipt, ReceiptSource, Routes, SplitShares, TransactionChanges, TransactionCustomUnit, WaypointCollection} from '@src/types/onyx/Transaction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import {clearByKey as clearPdfByOnyxKey} from './CachedPDFPaths'; @@ -10139,7 +10138,7 @@ function canIOUBePaid( iouReport: OnyxTypes.OnyxInputOrEntry, chatReport: OnyxTypes.OnyxInputOrEntry, policy: OnyxTypes.OnyxInputOrEntry, - transactions?: OnyxTypes.Transaction[] | SearchTransaction[], + transactions?: OnyxTypes.Transaction[], onlyShowPayElsewhere = false, chatReportRNVP?: OnyxTypes.ReportNameValuePairs, invoiceReceiverPolicy?: OnyxTypes.Policy, @@ -10212,7 +10211,7 @@ function canCancelPayment(iouReport: OnyxEntry, session: OnyxE function canSubmitReport( report: OnyxEntry, policy: OnyxEntry, - transactions: OnyxTypes.Transaction[] | SearchTransaction[], + transactions: OnyxTypes.Transaction[], allViolations: OnyxCollection | undefined, isReportArchived: boolean, ) { From b73f655c9e9f990c40dbda9a8d9f40b0e9588089 Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Thu, 20 Nov 2025 16:51:09 +0100 Subject: [PATCH 63/64] fixed opening wide rhp as super wide rhp after deleting transactions --- src/components/Search/index.tsx | 4 +++- src/components/WideRHPContextProvider/default.ts | 1 + src/components/WideRHPContextProvider/index.tsx | 15 +++++++++++++++ src/components/WideRHPContextProvider/types.ts | 3 +++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 61650daf1645..01ebe1b5fd55 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -263,7 +263,7 @@ function Search({ const {accountID, email} = useCurrentUserPersonalDetails(); const [isActionLoadingSet = new Set()] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}`, {canBeMissing: true, selector: isActionLoadingSetSelector}); - const {markReportIDAsMultiTransactionExpense} = useContext(WideRHPContext); + const {markReportIDAsMultiTransactionExpense, unmarkReportIDAsMultiTransactionExpense} = useContext(WideRHPContext); // Filter violations based on user visibility const filteredViolations = useMemo(() => { @@ -739,6 +739,8 @@ function Search({ if (item.transactions.length > 1) { markReportIDAsMultiTransactionExpense(reportID); + } else { + unmarkReportIDAsMultiTransactionExpense(reportID); } requestAnimationFrame(() => Navigation.navigate(ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID, backTo}))); diff --git a/src/components/WideRHPContextProvider/default.ts b/src/components/WideRHPContextProvider/default.ts index bad5e313fbdd..a1ea9d6c3862 100644 --- a/src/components/WideRHPContextProvider/default.ts +++ b/src/components/WideRHPContextProvider/default.ts @@ -7,6 +7,7 @@ const defaultWideRHPContextValue: WideRHPContextType = { cleanWideRHPRouteKey: () => {}, markReportIDAsExpense: () => {}, markReportIDAsMultiTransactionExpense: () => {}, + unmarkReportIDAsMultiTransactionExpense: () => {}, isReportIDMarkedAsExpense: () => false, isReportIDMarkedAsMultiTransactionExpense: () => false, dismissToFirstRHP: () => {}, diff --git a/src/components/WideRHPContextProvider/index.tsx b/src/components/WideRHPContextProvider/index.tsx index dcee4319a745..9fa01116f958 100644 --- a/src/components/WideRHPContextProvider/index.tsx +++ b/src/components/WideRHPContextProvider/index.tsx @@ -463,6 +463,19 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { }); }, []); + /** + * Removes a report ID from the multi-transaction expense reports set. + * This disables optimistic super wide RHP display for that specific report + * (e.g., when transactions are deleted or report no longer qualifies as multi-transaction) + */ + const unmarkReportIDAsMultiTransactionExpense = useCallback((reportID: string) => { + setMultiTransactionExpenseReportIDs((prev) => { + const newSet = new Set(prev); + newSet.delete(reportID); + return newSet; + }); + }, []); + /** * Checks if a report ID is marked as a multi-transaction expense report. * Used to determine if super wide RHP should be displayed optimistically. @@ -579,6 +592,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { dismissToSecondRHP, markReportIDAsExpense, markReportIDAsMultiTransactionExpense, + unmarkReportIDAsMultiTransactionExpense, isReportIDMarkedAsExpense, isReportIDMarkedAsMultiTransactionExpense, isWideRHPFocused, @@ -600,6 +614,7 @@ function WideRHPContextProvider({children}: React.PropsWithChildren) { dismissToSecondRHP, markReportIDAsExpense, markReportIDAsMultiTransactionExpense, + unmarkReportIDAsMultiTransactionExpense, isReportIDMarkedAsExpense, isReportIDMarkedAsMultiTransactionExpense, isWideRHPFocused, diff --git a/src/components/WideRHPContextProvider/types.ts b/src/components/WideRHPContextProvider/types.ts index c51eda9e816e..d3e3154eb297 100644 --- a/src/components/WideRHPContextProvider/types.ts +++ b/src/components/WideRHPContextProvider/types.ts @@ -28,6 +28,9 @@ type WideRHPContextType = { // Mark reportID as multi-transaction expense before condition check markReportIDAsMultiTransactionExpense: (reportID: string) => void; + // Unmark reportID as multi-transaction expense before condition check + unmarkReportIDAsMultiTransactionExpense: (reportID: string) => void; + // Check if reportID is marked as expense isReportIDMarkedAsExpense: (reportID: string) => boolean; From d9f30dcca49b3a4f67927bb0dc5b063c848a69b7 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Thu, 20 Nov 2025 17:22:30 +0100 Subject: [PATCH 64/64] Fix imports in IOU.ts --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index b4e563e85ba5..213a5afbf4e6 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -253,7 +253,7 @@ import type RecentlyUsedTags from '@src/types/onyx/RecentlyUsedTags'; import type {InvoiceReceiver, InvoiceReceiverType} from '@src/types/onyx/Report'; import type ReportAction from '@src/types/onyx/ReportAction'; import type {OnyxData} from '@src/types/onyx/Request'; -import {SearchTransaction} from '@src/types/onyx/SearchResults'; +import type {SearchTransaction} from '@src/types/onyx/SearchResults'; import type {Comment, Receipt, ReceiptSource, Routes, SplitShares, TransactionChanges, TransactionCustomUnit, WaypointCollection} from '@src/types/onyx/Transaction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import {clearByKey as clearPdfByOnyxKey} from './CachedPDFPaths';