From adf85d9a10cf51f8f4dec791f6a35ed8c39ebdf6 Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 30 Mar 2026 19:16:19 +0200 Subject: [PATCH 1/2] fix: dont show splash on OD signout --- src/Expensify.tsx | 4 +-- src/HybridAppHandler.tsx | 44 +++++++++++------------ src/SplashScreenStateContext.tsx | 7 ++-- src/libs/telemetry/bootsplashTelemetry.ts | 4 +-- 4 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/Expensify.tsx b/src/Expensify.tsx index 82900c0ef0a6..be2263ce973c 100644 --- a/src/Expensify.tsx +++ b/src/Expensify.tsx @@ -199,9 +199,7 @@ function Expensify() { Navigation.setIsNavigationReady(); }, []); - const [splashHideHasBeenCalled, setSplashHideHasBeenCalled] = useState(false); const onSplashHide = useCallback(() => { - setSplashHideHasBeenCalled(true); setSplashScreenState(CONST.BOOT_SPLASH_STATE.HIDDEN); endSpan(CONST.TELEMETRY.SPAN_OD_ND_TRANSITION); endSpan(CONST.TELEMETRY.SPAN_APP_STARTUP); @@ -294,7 +292,7 @@ function Expensify() { initialUrl={initialUrl} /> )} - {!splashHideHasBeenCalled && ( + {(isSplashVisible || isSplashReadyToBeHidden) && ( { - const loggedOutFromOldDot = !!hybridAppSettings.hybridApp.loggedOutFromOldDot; + const finalizeTransitionFromOldDot = (hybridAppSettings: HybridAppSettings) => { + const loggedOutFromOldDot = !!hybridAppSettings.hybridApp.loggedOutFromOldDot; - setupNewDotAfterTransitionFromOldDot(hybridAppSettings, tryNewDot).then(() => { - if (splashScreenState !== CONST.BOOT_SPLASH_STATE.VISIBLE) { - addBootsplashBreadcrumb('HybridAppHandler: Splash no longer VISIBLE, skipping state transition', {splashScreenState}); - return; - } - - if (loggedOutFromOldDot) { - setSplashScreenState(CONST.BOOT_SPLASH_STATE.HIDDEN); - endSpan(CONST.TELEMETRY.SPAN_OD_ND_TRANSITION_LOGGED_OUT); - } else { - setSplashScreenState(CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN); - } - }); - }, - [setSplashScreenState, splashScreenState, tryNewDot], - ); + setupNewDotAfterTransitionFromOldDot(hybridAppSettings, tryNewDot).then(() => { + if (loggedOutFromOldDot) { + endSpan(CONST.TELEMETRY.SPAN_OD_ND_TRANSITION_LOGGED_OUT); + } else { + setSplashScreenState(CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN); + } + }); + }; useEffect(() => { if (!CONFIG.IS_HYBRID_APP || isLoadingTryNewDot) { @@ -55,6 +45,14 @@ function HybridAppHandler() { addBootsplashBreadcrumb('HybridAppHandler: Settings received', {loggedOutFromOldDot: String(!!hybridAppSettings.hybridApp.loggedOutFromOldDot)}); + // Resolve splash state ASAP — this is the earliest moment we know + // whether the native splash is on screen or not + if (hybridAppSettings.hybridApp.loggedOutFromOldDot) { + setSplashScreenState(CONST.BOOT_SPLASH_STATE.HIDDEN); + } else { + setSplashScreenState(CONST.BOOT_SPLASH_STATE.VISIBLE); + } + if (hybridAppSettings.hybridApp.loggedOutFromOldDot) { startSpan(CONST.TELEMETRY.SPAN_OD_ND_TRANSITION_LOGGED_OUT, { name: CONST.TELEMETRY.SPAN_OD_ND_TRANSITION_LOGGED_OUT, @@ -71,7 +69,7 @@ function HybridAppHandler() { finalizeTransitionFromOldDot(hybridAppSettings); }); - }, [finalizeTransitionFromOldDot, isLoadingTryNewDot]); + }, [finalizeTransitionFromOldDot, isLoadingTryNewDot, setSplashScreenState]); return null; } diff --git a/src/SplashScreenStateContext.tsx b/src/SplashScreenStateContext.tsx index b07b2c068a89..272510e2b6fb 100644 --- a/src/SplashScreenStateContext.tsx +++ b/src/SplashScreenStateContext.tsx @@ -1,5 +1,6 @@ import React, {useContext, useEffect, useState} from 'react'; import type {ValueOf} from 'type-fest'; +import CONFIG from './CONFIG'; import CONST from './CONST'; import {addBootsplashBreadcrumb} from './libs/telemetry/bootsplashTelemetry'; import type ChildrenProps from './types/utils/ChildrenProps'; @@ -7,7 +8,7 @@ import type ChildrenProps from './types/utils/ChildrenProps'; type SplashScreenState = ValueOf; type SplashScreenStateContextType = { - splashScreenState: SplashScreenState; + splashScreenState: SplashScreenState | undefined; }; type SplashScreenActionsContextType = { @@ -15,7 +16,7 @@ type SplashScreenActionsContextType = { }; const SplashScreenStateContext = React.createContext({ - splashScreenState: CONST.BOOT_SPLASH_STATE.VISIBLE, + splashScreenState: undefined, }); const SplashScreenActionsContext = React.createContext({ @@ -29,7 +30,7 @@ function loadPostSplashScreenModules() { } function SplashScreenStateContextProvider({children}: ChildrenProps) { - const [splashScreenState, setSplashScreenStateRaw] = useState(CONST.BOOT_SPLASH_STATE.VISIBLE); + const [splashScreenState, setSplashScreenStateRaw] = useState(CONFIG.IS_HYBRID_APP ? undefined : CONST.BOOT_SPLASH_STATE.VISIBLE); const setSplashScreenState = (state: SplashScreenState) => { addBootsplashBreadcrumb(`splashScreenState changed to ${state}`); diff --git a/src/libs/telemetry/bootsplashTelemetry.ts b/src/libs/telemetry/bootsplashTelemetry.ts index 776177a99ac9..028c84d7feb8 100644 --- a/src/libs/telemetry/bootsplashTelemetry.ts +++ b/src/libs/telemetry/bootsplashTelemetry.ts @@ -16,7 +16,7 @@ function addBootsplashBreadcrumb(message: string, data?: Record, } type BootsplashGateStatus = { - splashScreenState: string; + splashScreenState: string | undefined; isOnyxMigrated: boolean; isCheckingPublicRoom: boolean; hasAttemptedToOpenPublicRoom: boolean; @@ -35,7 +35,7 @@ function startBootsplashMonitor(gateStatusRef: React.RefObject Date: Wed, 1 Apr 2026 14:45:46 +0200 Subject: [PATCH 2/2] fix: trigger hide on `shouldHideSplash` change --- .../SplashScreenHider/index.native.tsx | 17 +++++++++++------ src/components/SplashScreenHider/index.tsx | 15 +++++++++++---- src/components/SplashScreenHider/types.ts | 3 +++ 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/components/SplashScreenHider/index.native.tsx b/src/components/SplashScreenHider/index.native.tsx index 100bc59353ff..b9b8e6527ec4 100644 --- a/src/components/SplashScreenHider/index.native.tsx +++ b/src/components/SplashScreenHider/index.native.tsx @@ -1,4 +1,4 @@ -import {useCallback, useRef} from 'react'; +import {useEffect, useEffectEvent, useRef} from 'react'; import type {ViewStyle} from 'react-native'; import {StyleSheet} from 'react-native'; import Reanimated, {Easing, useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated'; @@ -9,7 +9,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import BootSplash from '@libs/BootSplash'; import type {SplashScreenHiderProps, SplashScreenHiderReturnType} from './types'; -function SplashScreenHider({onHide = () => {}}: SplashScreenHiderProps): SplashScreenHiderReturnType { +function SplashScreenHider({onHide, shouldHideSplash}: SplashScreenHiderProps): SplashScreenHiderReturnType { const styles = useThemeStyles(); const logoSizeRatio = BootSplash.logoSizeRatio || 1; @@ -24,8 +24,7 @@ function SplashScreenHider({onHide = () => {}}: SplashScreenHiderProps): SplashS })); const hideHasBeenCalled = useRef(false); - - const hide = useCallback(() => { + const hide = useEffectEvent(() => { // hide can only be called once if (hideHasBeenCalled.current) { return; @@ -52,13 +51,19 @@ function SplashScreenHider({onHide = () => {}}: SplashScreenHiderProps): SplashS ), ); }); - }, [opacity, scale, onHide]); + }); + + useEffect(() => { + if (!shouldHideSplash) { + return; + } + hide(); + }, [shouldHideSplash]); return ( {}}: SplashScreenHiderProps): SplashScreenHiderReturnType { - useEffect(() => { +function SplashScreenHider({onHide, shouldHideSplash}: SplashScreenHiderProps): SplashScreenHiderReturnType { + const hide = useEffectEvent(() => { BootSplash.hide().then(() => onHide()); - }, [onHide]); + }); + + useEffect(() => { + if (!shouldHideSplash) { + return; + } + hide(); + }, [shouldHideSplash]); return null; } diff --git a/src/components/SplashScreenHider/types.ts b/src/components/SplashScreenHider/types.ts index e48bbdcee307..0f0dff825e4c 100644 --- a/src/components/SplashScreenHider/types.ts +++ b/src/components/SplashScreenHider/types.ts @@ -3,6 +3,9 @@ import type {ReactNode} from 'react'; type SplashScreenHiderProps = { /** Splash screen has been hidden */ onHide: () => void; + + /** Whether the splash screen should be hidden */ + shouldHideSplash: boolean; }; type SplashScreenHiderReturnType = ReactNode;