diff --git a/src/languages/en.ts b/src/languages/en.ts index b5adf3db2d2e4..a225c5f01d339 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1443,7 +1443,7 @@ const translations = { lossOfUnsubmittedData: `Merging your accounts is irreversible and will result in the loss of any unsubmitted expenses for `, enterMagicCode: `To continue, please enter the magic code sent to `, errors: { - incorrect2fa: 'Incorrect two-factor authentication code. Please try again.', + incorrectMagicCode: 'Incorrect or invalid magic code. Please try again or request a new code.', fallback: 'Something went wrong. Please try again later.', }, }, diff --git a/src/languages/es.ts b/src/languages/es.ts index dc4cdc9fa59a1..c6ac17afdc32f 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1442,7 +1442,7 @@ const translations = { lossOfUnsubmittedData: `Fusionar tus cuentas es irreversible y resultará en la pérdida de cualquier gasto no enviado de `, enterMagicCode: `Para continuar, por favor introduce el código mágico enviado a `, errors: { - incorrect2fa: 'Código de autenticación de dos factores incorrecto. Por favor, inténtalo de nuevo.', + incorrectMagicCode: 'Código mágico incorrecto o no válido. Inténtalo de nuevo o solicita otro código.', fallback: 'Ha ocurrido un error. Por favor, inténtalo mas tarde.', }, }, diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index bd13b29b1dd4b..f8c0b519c996e 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -2,6 +2,7 @@ import type {ParamListBase} from '@react-navigation/routers'; import React from 'react'; import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; import Animations from '@libs/Navigation/PlatformStackNavigation/navigationOptions/animation'; +import type {PlatformStackNavigationOptions} from '@libs/Navigation/PlatformStackNavigation/types'; import type { AddPersonalBankAccountNavigatorParamList, AddUnreportedExpensesParamList, @@ -47,6 +48,12 @@ import useModalStackScreenOptions from './useModalStackScreenOptions'; type Screens = Partial React.ComponentType>>; +const OPTIONS_PER_SCREEN: Partial> = { + [SCREENS.SETTINGS.MERGE_ACCOUNTS.MERGE_RESULT]: { + animationTypeForReplace: 'push', + }, +}; + /** * Create a modal stack navigator with an array of sub-screens. * @@ -66,6 +73,7 @@ function createModalStackNavigator(screens: Scr key={name} name={name} getComponent={(screens as Required)[name as Screen]} + options={OPTIONS_PER_SCREEN[name as Screen]} /> ))} diff --git a/src/pages/settings/Security/MergeAccounts/AccountValidatePage.tsx b/src/pages/settings/Security/MergeAccounts/AccountValidatePage.tsx index 0df368c1ac4a8..614dfb3bf62fe 100644 --- a/src/pages/settings/Security/MergeAccounts/AccountValidatePage.tsx +++ b/src/pages/settings/Security/MergeAccounts/AccountValidatePage.tsx @@ -65,7 +65,7 @@ const getAuthenticationErrorKey = (err: string): TranslationPaths | null => { } if (err.includes('Invalid validateCode')) { - return 'mergeAccountsPage.accountValidate.errors.incorrect2fa'; + return 'mergeAccountsPage.accountValidate.errors.incorrectMagicCode'; } return 'mergeAccountsPage.accountValidate.errors.fallback'; @@ -137,7 +137,7 @@ function AccountValidatePage() { { - Navigation.goBack(ROUTES.SETTINGS_MERGE_ACCOUNTS.getRoute(email)); + Navigation.goBack(ROUTES.SETTINGS_MERGE_ACCOUNTS.getRoute()); }} shouldDisplayHelpButton={false} /> diff --git a/src/pages/settings/Security/MergeAccounts/MergeResultPage.tsx b/src/pages/settings/Security/MergeAccounts/MergeResultPage.tsx index 8f92059e34cae..dadce46094b20 100644 --- a/src/pages/settings/Security/MergeAccounts/MergeResultPage.tsx +++ b/src/pages/settings/Security/MergeAccounts/MergeResultPage.tsx @@ -1,6 +1,7 @@ import HybridAppModule from '@expensify/react-native-hybrid-app'; import {useRoute} from '@react-navigation/native'; -import React, {useContext, useMemo} from 'react'; +import React, {useContext, useEffect, useMemo} from 'react'; +import {InteractionManager} from 'react-native'; import {useOnyx} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import ConfirmationPage from '@components/ConfirmationPage'; @@ -23,7 +24,7 @@ import CONFIG from '@src/CONFIG'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import type SCREENS from '@src/SCREENS'; +import SCREENS from '@src/SCREENS'; function MergeResultPage() { const styles = useThemeStyles(); @@ -228,6 +229,20 @@ function MergeResultPage() { }; }, [setRootStatusBarEnabled, login, translate, userEmailOrPhone, styles]); + useEffect(() => { + /** + * If the result is success, we need to remove the initial screen from the navigation state + * so that the back button closes the modal instead of going back to the initial screen. + */ + if (result !== CONST.MERGE_ACCOUNT_RESULTS.SUCCESS) { + return; + } + + InteractionManager.runAfterInteractions(() => { + Navigation.removeScreenFromNavigationState(SCREENS.SETTINGS.MERGE_ACCOUNTS.ACCOUNT_DETAILS); + }); + }, [result]); + const { heading, headingStyle, @@ -253,7 +268,7 @@ function MergeResultPage() { title={translate('mergeAccountsPage.mergeAccount')} shouldShowBackButton={result !== CONST.MERGE_ACCOUNT_RESULTS.SUCCESS} onBackButtonPress={() => { - Navigation.goBack(ROUTES.SETTINGS_MERGE_ACCOUNTS.getRoute(login)); + Navigation.goBack(ROUTES.SETTINGS_MERGE_ACCOUNTS.getRoute()); }} shouldDisplayHelpButton={false} />