Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[$250] DEV : When clicking to send the magic code to verify the secondary email, a blank page appears briefly before the page to enter the code. #53884

Open
1 of 8 tasks
m-natarajan opened this issue Dec 10, 2024 · 34 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Needs Reproduction Reproducible steps needed retest-weekly Apply this label if you want this issue tested on a Weekly basis by Applause

Comments

@m-natarajan
Copy link

m-natarajan commented Dec 10, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number:
Reproducible in staging?: dev
Reproducible in production?: dev
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @brunovjk
Slack conversation (hyperlinked to channel name): ts_external_expensify_bugs

Action Performed:

  1. Log into the account.
  2. Navigate to Account settings > Profile > Contact methods.
  3. Add a secondary login.
  4. Enter the magic code for the existing account to allow the secondary email to be added.
  5. Click to send the magic code to verify the secondary email.

Expected Result:

The user is taken directly to the page to enter the code.

Actual Result:

A blank page appears briefly before navigating to the page to enter the code.

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
393837072-0b45c58f-ce4e-4e94-bad7-f7f0057d5916.mov

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021867385191571001621
  • Upwork Job ID: 1867385191571001621
  • Last Price Increase: 2024-12-13
Issue OwnerCurrent Issue Owner: @ZhenjaHorbach
@m-natarajan m-natarajan added Daily KSv2 Needs Reproduction Reproducible steps needed Bug Something is broken. Auto assigns a BugZero manager. retest-weekly Apply this label if you want this issue tested on a Weekly basis by Applause labels Dec 10, 2024
Copy link

melvin-bot bot commented Dec 10, 2024

Triggered auto assignment to @MitchExpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@MelvinBot
Copy link

This has been labelled "Needs Reproduction". Follow the steps here: https://stackoverflowteams.com/c/expensify/questions/16989

@jacobkim9881
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

When entering one of contacts, RHP modal opens twice.

What is the root cause of that problem?

<ScreenWrapper
onEntryTransitionEnd={() => validateCodeFormRef.current?.focus?.()}
testID={ContactMethodDetailsPage.displayName}
>
<HeaderWithBackButton
title={formattedContactMethod}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS.getRoute(backTo))}
/>
<ScrollView keyboardShouldPersistTaps="handled">
{isFailedAddContactMethod && (
<ErrorMessageRow
errors={ErrorUtils.getLatestErrorField(loginData, 'addedLogin')}
errorRowStyles={[themeStyles.mh5, themeStyles.mv3]}
onClose={() => {
User.clearContactMethod(contactMethod);
User.clearUnvalidatedNewContactMethodAction();
Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS.getRoute(backTo));
}}
canDismissError
/>
)}
<ValidateCodeActionModal
title={formattedContactMethod}
onModalHide={() => {}}
hasMagicCodeBeenSent={hasMagicCodeBeenSent}
isVisible={isValidateCodeActionModalVisible && !loginData.validatedDate && !!loginData}
validatePendingAction={loginData.pendingFields?.validateCodeSent}
handleSubmitForm={(validateCode) => User.validateSecondaryLogin(loginList, contactMethod, validateCode)}
validateError={!isEmptyObject(validateLoginError) ? validateLoginError : ErrorUtils.getLatestErrorField(loginData, 'validateCodeSent')}
clearError={() => User.clearContactMethodErrors(contactMethod, !isEmptyObject(validateLoginError) ? 'validateLogin' : 'validateCodeSent')}
onClose={() => {
Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS.getRoute(backTo));
setIsValidateCodeActionModalVisible(false);
}}
sendValidateCode={() => User.requestContactMethodValidateCode(contactMethod)}
descriptionPrimary={translate('contacts.enterMagicCode', {contactMethod})}
/>

Here at details page, though modal is opened other modal is placed by <ValidateCodeActionModal>.

What changes do you think we should make in order to solve the problem?

Instead of using <ValidateCodeActionModal>, we can replace it with <ValidateCodeForm>

Then the fix code would look like:

<ScreenWrapper
onEntryTransitionEnd={() => validateCodeFormRef.current?.focus?.()}
testID={ContactMethodDetailsPage.displayName}
>
<HeaderWithBackButton
title={formattedContactMethod}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS.getRoute(backTo))}
/>
<ScrollView keyboardShouldPersistTaps="handled">
{isFailedAddContactMethod && (
<ErrorMessageRow
errors={ErrorUtils.getLatestErrorField(loginData, 'addedLogin')}
errorRowStyles={[themeStyles.mh5, themeStyles.mv3]}
onClose={() => {
User.clearContactMethod(contactMethod);
User.clearUnvalidatedNewContactMethodAction();
Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS.getRoute(backTo));
}}
canDismissError
/>
)}

                <View style={[themeStyles.ph5, themeStyles.mt3, themeStyles.mb7, themeStyles.flex1]}>
                   <Text style={[themeStyles.mb3]}>{translate('contacts.enterMagicCode', {contactMethod})}</Text>
                   <ValidateCodeForm   
                       validateCodeAction={validateCodeAction}
                       validatePendingAction={loginData.pendingFields?.validateCodeSent}
                       validateError={!isEmptyObject(validateLoginError) ? validateLoginError : ErrorUtils.getLatestErrorField(loginData, 'validateCodeSent')}
                       handleSubmitForm={(validateCode) => User.validateSecondaryLogin(loginList, contactMethod, validateCode)}
                       sendValidateCode={() => User.requestContactMethodValidateCode(contactMethod)}
                       clearError={() => User.clearContactMethodErrors(contactMethod, !isEmptyObject(validateLoginError) ? 'validateLogin' : 'validateCodeSent')}
                       buttonStyles={[themeStyles.justifyContentEnd, themeStyles.flex1]}
                       ref={validateCodeFormRef}
                       hasMagicCodeBeenSent={hasMagicCodeBeenSent}
                   />
                </View>

What alternative solutions did you explore? (Optional)

N/A

@hoangzinh
Copy link
Contributor

I can reproduce it. Actually, it's hard to see the blank page on my end because the blank page will be hidden almost immediately when navigating to the secondary email. However, it's easy to reproduce if we record it and then watch it closely.

Screenshot 2024-12-11 at 17 24 11

Click here to view recordings
Screen.Recording.2024-12-11.at.17.22.21.mov

@MitchExpensify MitchExpensify added the External Added to denote the issue can be worked on by a contributor label Dec 13, 2024
@melvin-bot melvin-bot bot changed the title DEV : When clicking to send the magic code to verify the secondary email, a blank page appears briefly before the page to enter the code. [$250] DEV : When clicking to send the magic code to verify the secondary email, a blank page appears briefly before the page to enter the code. Dec 13, 2024
Copy link

melvin-bot bot commented Dec 13, 2024

Job added to Upwork: https://www.upwork.com/jobs/~021867385191571001621

@melvin-bot melvin-bot bot added Overdue Help Wanted Apply this label when an issue is open to proposals by contributors labels Dec 13, 2024
Copy link

melvin-bot bot commented Dec 13, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @ZhenjaHorbach (External)

@melvin-bot melvin-bot bot removed the Overdue label Dec 13, 2024
@MitchExpensify MitchExpensify moved this to First Cohort - MEDIUM or LOW in [#whatsnext] #migrate Dec 13, 2024
@ZhenjaHorbach
Copy link
Contributor

@hoangzinh
Do you want to take it ?

@hoangzinh
Copy link
Contributor

yes, I do @ZhenjaHorbach ❤️. @MitchExpensify can you assign this issue to me as a C as I was able to reproduce it? Thank you.

@ZhenjaHorbach ZhenjaHorbach removed their assignment Dec 13, 2024
@daledah
Copy link
Contributor

daledah commented Dec 16, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

  • A blank page appears briefly before navigating to the page to enter the code.

What is the root cause of that problem?

  • When navigating to the ContactMethodDetailsPage, it transitions with a right-to-left swipe animation. During this time, only the HeaderWithBackButton is visible, as shown in the video.

  • While the screen transition animation is ongoing, a modal is displayed if the condition specified in the following logic is met:

isVisible={isValidateCodeActionModalVisible && !loginData.validatedDate && !!loginData}

  • This explains why a blank screen briefly appears before navigating to the code entry page.

What changes do you think we should make in order to solve the problem?

  • Instead of showing a blank screen, we should display a loading indicator to prevent user confusion. This way, users understand that the data and UI are loading and will be ready shortly. We can do it by using:
            {shouldShowModal ? (
                <FullScreenLoadingIndicator />
            ) : (
                <HeaderWithBackButton
                    title={formattedContactMethod}
                    onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS.getRoute(backTo))}
                />
            )}

instead of:

<HeaderWithBackButton
title={formattedContactMethod}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS.getRoute(backTo))}
/>

  • Note that shouldShowModal = isValidateCodeActionModalVisible && !loginData.validatedDate && !!loginData

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Dec 16, 2024
Copy link

melvin-bot bot commented Dec 16, 2024

@MitchExpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot removed Help Wanted Apply this label when an issue is open to proposals by contributors Overdue labels Dec 16, 2024
@MitchExpensify
Copy link
Contributor

Done, what do you think of the proposal above, @hoangzinh ?

@hoangzinh
Copy link
Contributor

Ah I'm reviewing proposals. Btw, @MitchExpensify could you help to remove Needs Reproduction
retest-weekly and add back Help Wanted label? Thank you.

@hoangzinh
Copy link
Contributor

hoangzinh commented Dec 16, 2024

@jacobkim9881 Thanks for posting a proposal. Can you share your recording result? It seems we lost the screen transition with that approach. Btw, we used to use ValidateCodeForm previously, but it has been replaced by ValidateCodeActionModal after this PR #49445

@hoangzinh
Copy link
Contributor

hoangzinh commented Dec 16, 2024

@daledah Thanks for posting a proposal. Can you also share your recording result? I think your solution would cause a regression bug after validating a contact, it would show a loading indicator forever. Btw, can you also elaborate the condition here is delayed to be true? (isValidateCodeActionModalVisible comes from useState and loginData comes from Onxy, however, we already show a loading indicator here when data is loading from Onyx)

isVisible={isValidateCodeActionModalVisible && !loginData.validatedDate && !!loginData}

@daledah
Copy link
Contributor

daledah commented Dec 17, 2024

I think your solution would cause a regression bug after validating a contact, it would show a loading indicator forever

I tried applying my solution and it works properly. After validating a contact, there is no loading indicator is shown since we will call:

setIsValidateCodeActionModalVisible(false);

onClose. And refer to my solution, we only display the loading indicator if the modal is showing:

            {shouldShowModal ? (
                <FullScreenLoadingIndicator />
            ) : (
                <HeaderWithBackButton
                    title={formattedContactMethod}
                    onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS.getRoute(backTo))}
                />
            )}

Here is the video:

Screen.Recording.2024-12-17.at.10.16.24.mov

@daledah
Copy link
Contributor

daledah commented Dec 17, 2024

can you also elaborate the condition here is delayed to be true? (isValidateCodeActionModalVisible comes from useState and loginData comes from Onxy, however, we already show a loading indicator here when data is loading from Onyx)

What do you mean by "delayed to be true" here?

@hoangzinh
Copy link
Contributor

hoangzinh commented Dec 17, 2024

I mean it should be true when we render ValidateCodeActionModal component. Is there any case it could be false (given we're in the context of an unverified 2nd contact method)?

@jacobkim9881
Copy link
Contributor

Thanks for posting a proposal. Can you share your recording result?

It seems the issue isn't reproducible from my side.

@hoangzinh
Copy link
Contributor

I am still able to reproduce it

Screenshot 2024-12-17 at 17 43 30

@daledah
Copy link
Contributor

daledah commented Dec 17, 2024

I mean it should be true when we render ValidateCodeActionModal component. Is there any case it could be false (given we're in the context of an unverified 2nd contact method)?

I believe this occurs because, in React, state updates are asynchronous, and the rendering process doesn't happen immediately after the state or props change. React batches updates for performance optimization, which can sometimes cause a slight delay in reflecting the updated data in the UI.

@hoangzinh
Copy link
Contributor

@daledah can you share a recording with console.log of isValidateCodeActionModalVisible and loginData? I would like to check which data is asynchronous updated as you mentioned. Thank you.

Besides that, I think your solution isn't looking good. For example, after verifying the account, there is a redundant page behind when App goBack to the contacts page
Screenshot 2024-12-17 at 22 26 07

@daledah
Copy link
Contributor

daledah commented Dec 18, 2024

can you share a recording with console.log of isValidateCodeActionModalVisible and loginData? I would like to check which data is asynchronous updated as you mentioned. Thank you.

  • Here is the video:
Screen.Recording.2024-12-18.at.18.14.24.mov

Besides that, I think your solution isn't looking good. For example, after verifying the account, there is a redundant page behind when App goBack to the contacts page

  • Thanks. I think this bug is not a regression from my solution but I am investigating the solution to address it.

@jacobkim9881
Copy link
Contributor

It seems we lost the screen transition with that approach.

@hoangzinh This cause the transition issue

hasMagicCodeBeenSent={hasMagicCodeBeenSent}

of

of

clear() {
lastFocusedIndex.current = 0;
setInputAndIndex(0);
inputRefs.current?.focus();
onChangeTextProp('');

But the code form's focus() is already used here

onEntryTransitionEnd={() => validateCodeFormRef.current?.focus?.()}

So I have deleted hasMagicCodeBeenSent.

expensify-test3-2024-12-18_20.30.00.mp4

@jacobkim9881
Copy link
Contributor

Btw, we used to use ValidateCodeForm previously, but it has been replaced by ValidateCodeActionModal after this PR #49445
@hoangzinh Then reverting the details page of the PR would be better.

@hoangzinh
Copy link
Contributor

@daledah based on your recording, it seems isValidateCodeActionModalVisible is always true in this case, isn't it?

Screenshot 2024-12-18 at 19 01 23

@hoangzinh
Copy link
Contributor

Then reverting the details page of the PR would be better.

@jacobkim9881 sorry, what would you like to revert?

@jacobkim9881
Copy link
Contributor

@hoangzinh
Copy link
Contributor

@jacobkim9881 I'm unsure of that way. The reason why we changed to use ValidateCodeActionModal is because of

Let's use this new component and remove any other usages that could lead people to reintroduce the wrong usage/ component.

As described in the issues' description #49270

@jacobkim9881
Copy link
Contributor

jacobkim9881 commented Dec 19, 2024

Let's use this new component and remove any other usages that could lead people to reintroduce the wrong usage/ component.

@hoangzinh I understood we can't revert.

It seems there are 2 <ValidateCodeForm> at @components/ValidateCodeActionModal and at src/pages/settings/Profile/Contacts each.

@mvtglobally
Copy link

Issue not reproducible during KI retests. (First week)

@melvin-bot melvin-bot bot added the Overdue label Dec 23, 2024
Copy link

melvin-bot bot commented Dec 23, 2024

@hoangzinh, @MitchExpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@MitchExpensify
Copy link
Contributor

Not overdue, trying to reproduce

@melvin-bot melvin-bot bot removed the Overdue label Dec 23, 2024
Copy link

melvin-bot bot commented Dec 24, 2024

@hoangzinh @MitchExpensify this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@hoangzinh
Copy link
Contributor

I can still reproduce this bug by slow-playing recording
Screenshot 2024-12-26 at 17 33 47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Needs Reproduction Reproducible steps needed retest-weekly Apply this label if you want this issue tested on a Weekly basis by Applause
Projects
Status: First Cohort - MEDIUM or LOW
Development

No branches or pull requests

8 participants