diff --git a/native/chat/thread-screen-pruner.react.js b/native/chat/thread-screen-pruner.react.js --- a/native/chat/thread-screen-pruner.react.js +++ b/native/chat/thread-screen-pruner.react.js @@ -10,7 +10,6 @@ import { useActiveThread } from '../navigation/nav-selectors'; import { NavContext } from '../navigation/navigation-context'; import { - getStateFromNavigatorRoute, getThreadIDFromRoute, getChildRouteFromNavigatorRoute, } from '../navigation/navigation-utils'; @@ -45,11 +44,17 @@ appRoute, TabNavigatorRouteName, ); + if (!tabRoute) { + return null; + } const chatRoute = getChildRouteFromNavigatorRoute( tabRoute, ChatRouteName, ); - return getStateFromNavigatorRoute(chatRoute); + if (!chatRoute?.state) { + return null; + } + return chatRoute.state; }, [navContext]); const inStackThreadIDs = React.useMemo(() => { diff --git a/native/navigation/navigation-utils.js b/native/navigation/navigation-utils.js --- a/native/navigation/navigation-utils.js +++ b/native/navigation/navigation-utils.js @@ -152,8 +152,11 @@ function getChildRouteFromNavigatorRoute( parentRoute: PossiblyStaleRoute<>, childRouteName: string, -): PossiblyStaleRoute<> { - const parentState = getStateFromNavigatorRoute(parentRoute); +): ?PossiblyStaleRoute<> { + if (!parentRoute.state) { + return null; + } + const parentState = parentRoute.state; const childRoute = parentState.routes.find( route => route.name === childRouteName, );