diff --git a/src/pages/ErrorPage/NotFoundPage.tsx b/src/pages/ErrorPage/NotFoundPage.tsx index 9211571eb7c71..0de487bec12a7 100644 --- a/src/pages/ErrorPage/NotFoundPage.tsx +++ b/src/pages/ErrorPage/NotFoundPage.tsx @@ -1,3 +1,4 @@ +import {useRoute} from '@react-navigation/native'; import React from 'react'; import type {FullPageNotFoundViewProps} from '@components/BlockingViews/FullPageNotFoundView'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; @@ -7,6 +8,8 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import Navigation from '@libs/Navigation/Navigation'; import useAbsentPageSpan from '@libs/telemetry/useAbsentPageSpan'; import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; +import SCREENS from '@src/SCREENS'; type NotFoundPageProps = { onBackButtonPress?: () => void; @@ -21,6 +24,8 @@ function NotFoundPage({onBackButtonPress = () => Navigation.goBack(), isReportRe const {isSmallScreenWidth} = useResponsiveLayout(); const topmostReportId = Navigation.getTopmostReportId(); const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${topmostReportId}`); + const route = useRoute(); + const isOnGenericErrorScreen = route.name === SCREENS.NOT_FOUND; useAbsentPageSpan(); @@ -46,6 +51,7 @@ function NotFoundPage({onBackButtonPress = () => Navigation.goBack(), isReportRe }} // eslint-disable-next-line react/jsx-props-no-spreading {...fullPageNotFoundViewProps} + onLinkPress={isOnGenericErrorScreen ? () => Navigation.goBack(ROUTES.HOME) : fullPageNotFoundViewProps.onLinkPress} /> );