Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ 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<SettingsNavigatorParamList, typeof SCREENS.SETTINGS.PROFILE.NEW_CONTACT_METHOD>;

Expand Down Expand Up @@ -163,7 +162,7 @@ function NewContactMethodPage({route}: NewContactMethodPageProps) {
User.clearContactMethodErrors(addSMSDomainIfPhoneNumber(pendingContactAction?.contactMethod ?? contactMethod), 'addedLogin');
}}
onClose={() => {
if (!isEmptyObject(loginData?.errorFields) && pendingContactAction?.contactMethod) {
if (pendingContactAction?.contactMethod) {
Comment on lines -166 to +165
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it safe to not check loginData?.errorFields here @mkzie2? I tested it and it does solve our problem, but I was thinking about Shahidullah-Muffakir's proposal, do you think it makes sense? I find it strange that I can reproduce the issue only if I close the error manually, otherwise everything happens normally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brunovjk It's safe because we've updated contactMethod to null in successData when adding a new contact method successfully. In the past, the bug doesn't happen because if (loginData?.errorFields && pendingContactAction?.contactMethod) { this condition is always matched when we close the validate code modal.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, that makes sense, thanks for clarifying. Finishing the checklist.

User.clearContactMethod(pendingContactAction?.contactMethod);
User.clearUnvalidatedNewContactMethodAction();
}
Expand Down