diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 20bca969468a..e23422d083ca 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -443,6 +443,7 @@ function addNewContactMethod(contactMethod: string, validateCode = '') { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PENDING_CONTACT_ACTION, value: { + contactMethod: null, validateCodeSent: null, actionVerified: true, errorFields: { diff --git a/src/pages/settings/Profile/Contacts/NewContactMethodPage.tsx b/src/pages/settings/Profile/Contacts/NewContactMethodPage.tsx index f662e7e4406b..c6ed5ababa6a 100644 --- a/src/pages/settings/Profile/Contacts/NewContactMethodPage.tsx +++ b/src/pages/settings/Profile/Contacts/NewContactMethodPage.tsx @@ -30,6 +30,7 @@ import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import INPUT_IDS from '@src/types/form/NewContactMethodForm'; import type {Errors} from '@src/types/onyx/OnyxCommon'; +import {isEmptyObject} from '@src/types/utils/EmptyObject'; type NewContactMethodPageProps = PlatformStackScreenProps; @@ -162,7 +163,7 @@ function NewContactMethodPage({route}: NewContactMethodPageProps) { User.clearContactMethodErrors(addSMSDomainIfPhoneNumber(pendingContactAction?.contactMethod ?? contactMethod), 'addedLogin'); }} onClose={() => { - if (loginData?.errorFields && pendingContactAction?.contactMethod) { + if (!isEmptyObject(loginData?.errorFields) && pendingContactAction?.contactMethod) { User.clearContactMethod(pendingContactAction?.contactMethod); User.clearUnvalidatedNewContactMethodAction(); }