From 86ba9ba77931d285c4539a0a630aa7fcc88e4fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Wed, 13 Nov 2024 18:55:04 -0600 Subject: [PATCH] Merge pull request #52513 from Expensify/francois-fix-typecheck Re-add removed `route` param (cherry picked from commit 99da1ac87df0510567d93c8d7601f1c665ead485) (CP triggered by mountiny) --- .../settings/Security/TwoFactorAuth/Steps/CodesStep.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx b/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx index 56bb7e0c52ab..e104397a7936 100644 --- a/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx +++ b/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx @@ -1,3 +1,5 @@ +import type {RouteProp} from '@react-navigation/native'; +import {useRoute} from '@react-navigation/native'; import React, {useEffect, useMemo, useState} from 'react'; import {ActivityIndicator, View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; @@ -19,7 +21,7 @@ import {READ_COMMANDS} from '@libs/API/types'; import Clipboard from '@libs/Clipboard'; import * as ErrorUtils from '@libs/ErrorUtils'; import localFileDownload from '@libs/localFileDownload'; -import type {BackToParams} from '@libs/Navigation/types'; +import type {BackToParams, SettingsNavigatorParamList} from '@libs/Navigation/types'; import StepWrapper from '@pages/settings/Security/TwoFactorAuth/StepWrapper/StepWrapper'; import useTwoFactorAuthContext from '@pages/settings/Security/TwoFactorAuth/TwoFactorAuthContext/useTwoFactorAuth'; import * as Session from '@userActions/Session'; @@ -27,6 +29,7 @@ import * as TwoFactorAuthActions from '@userActions/TwoFactorAuthActions'; import * as User from '@userActions/User'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import type SCREENS from '@src/SCREENS'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; type CodesStepProps = BackToParams; @@ -46,6 +49,7 @@ function CodesStep({backTo}: CodesStepProps) { const isUserValidated = user?.validated; const contactMethod = account?.primaryLogin ?? ''; + const route = useRoute>(); const loginData = useMemo(() => loginList?.[contactMethod], [loginList, contactMethod]); const validateLoginError = ErrorUtils.getEarliestErrorField(loginData, 'validateLogin'); @@ -73,7 +77,7 @@ function CodesStep({backTo}: CodesStepProps) { }} // When the 2FA code step is open from Xero flow, we don't need to pass backTo because we build the necessary root route // from the backTo param in the route (in getMatchingRootRouteForRHPRoute) and goBack will not need a fallbackRoute. - onBackButtonPress={() => TwoFactorAuthActions.quitAndNavigateBack(route.params.forwardTo?.includes(READ_COMMANDS.CONNECT_POLICY_TO_XERO) ? '' : backTo)} + onBackButtonPress={() => TwoFactorAuthActions.quitAndNavigateBack(route?.params?.forwardTo?.includes(READ_COMMANDS.CONNECT_POLICY_TO_XERO) ? '' : backTo)} > {!!isUserValidated && (