Skip to content

Commit 86ba9ba

Browse files
marcochavezfOSBotify
authored andcommitted
Merge pull request #52513 from Expensify/francois-fix-typecheck
Re-add removed `route` param (cherry picked from commit 99da1ac) (CP triggered by mountiny)
1 parent 801218b commit 86ba9ba

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type {RouteProp} from '@react-navigation/native';
2+
import {useRoute} from '@react-navigation/native';
13
import React, {useEffect, useMemo, useState} from 'react';
24
import {ActivityIndicator, View} from 'react-native';
35
import {useOnyx} from 'react-native-onyx';
@@ -19,14 +21,15 @@ import {READ_COMMANDS} from '@libs/API/types';
1921
import Clipboard from '@libs/Clipboard';
2022
import * as ErrorUtils from '@libs/ErrorUtils';
2123
import localFileDownload from '@libs/localFileDownload';
22-
import type {BackToParams} from '@libs/Navigation/types';
24+
import type {BackToParams, SettingsNavigatorParamList} from '@libs/Navigation/types';
2325
import StepWrapper from '@pages/settings/Security/TwoFactorAuth/StepWrapper/StepWrapper';
2426
import useTwoFactorAuthContext from '@pages/settings/Security/TwoFactorAuth/TwoFactorAuthContext/useTwoFactorAuth';
2527
import * as Session from '@userActions/Session';
2628
import * as TwoFactorAuthActions from '@userActions/TwoFactorAuthActions';
2729
import * as User from '@userActions/User';
2830
import CONST from '@src/CONST';
2931
import ONYXKEYS from '@src/ONYXKEYS';
32+
import type SCREENS from '@src/SCREENS';
3033
import {isEmptyObject} from '@src/types/utils/EmptyObject';
3134

3235
type CodesStepProps = BackToParams;
@@ -46,6 +49,7 @@ function CodesStep({backTo}: CodesStepProps) {
4649

4750
const isUserValidated = user?.validated;
4851
const contactMethod = account?.primaryLogin ?? '';
52+
const route = useRoute<RouteProp<SettingsNavigatorParamList, typeof SCREENS.SETTINGS.TWO_FACTOR_AUTH>>();
4953

5054
const loginData = useMemo(() => loginList?.[contactMethod], [loginList, contactMethod]);
5155
const validateLoginError = ErrorUtils.getEarliestErrorField(loginData, 'validateLogin');
@@ -73,7 +77,7 @@ function CodesStep({backTo}: CodesStepProps) {
7377
}}
7478
// When the 2FA code step is open from Xero flow, we don't need to pass backTo because we build the necessary root route
7579
// from the backTo param in the route (in getMatchingRootRouteForRHPRoute) and goBack will not need a fallbackRoute.
76-
onBackButtonPress={() => TwoFactorAuthActions.quitAndNavigateBack(route.params.forwardTo?.includes(READ_COMMANDS.CONNECT_POLICY_TO_XERO) ? '' : backTo)}
80+
onBackButtonPress={() => TwoFactorAuthActions.quitAndNavigateBack(route?.params?.forwardTo?.includes(READ_COMMANDS.CONNECT_POLICY_TO_XERO) ? '' : backTo)}
7781
>
7882
<ScrollView contentContainerStyle={styles.flexGrow1}>
7983
{!!isUserValidated && (

0 commit comments

Comments
 (0)