Skip to content

[HOLD for payment 2023-11-09] [$500] Wallet - Once after login, debit card page exits without open #30024

Closed

Description

@kbecciv

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 1.3.87.1
Reproducible in staging?: y
Reproducible in production?: y
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: @dhanashree-sawant
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1697728465566479

Action Performed:

  1. Open the app
  2. If logged in then log out
  3. Login again
  4. Open settings->wallet
  5. Click Add payment method and click bank account
  6. Before it redirects, click on back
  7. Again click on add payment method
  8. Click on debit card and observe that it opens the debit card page for a second and closes it

Expected Result:

App should not close debit card page directly after opening

Actual Result:

App closes debit card page directly after opening once after login

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Android: Native
Android: mWeb Chrome
Android.chrome.back.issue.debit.card.mp4
iOS: Native
iOS: mWeb Safari
ios.safari.back.issue.debit.card.mov
MacOS: Chrome / Safari
windows.chrome.debit.card.back.issue.mp4
mac.chrome.first.time.after.login.debit.card.issue.mov
Recording.5087.mp4
MacOS: Desktop

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01c55ad3e6cb6401c8
  • Upwork Job ID: 1715100322264395776
  • Last Price Increase: 2023-10-19
  • Automatic offers:
    • Pujan92 | Contributor | 27357327
    • dhanashree-sawant | Reporter | 27357331

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 19, 2023
  2. changed the title [-]Wallet - Once after login, debit card page exits without open[/-] [+][$500] Wallet - Once after login, debit card page exits without open[/+] on Oct 19, 2023
  3. melvin-bot commented on Oct 19, 2023

    @melvin-bot

    Triggered auto assignment to @joekaufmanexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  4. melvin-bot commented on Oct 19, 2023

    @melvin-bot
  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 19, 2023
  6. melvin-bot commented on Oct 19, 2023

    @melvin-bot

    Bug0 Triage Checklist (Main S/O)

    • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
    • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
      • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
    • This bug is reproducible using the reproduction steps in the OP. S/O
      • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
      • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
    • This issue is filled out as thoroughly and clearly as possible
      • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
    • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
  7. melvin-bot commented on Oct 19, 2023

    @melvin-bot

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

  8. ZhenjaHorbach commented on Oct 19, 2023

    @ZhenjaHorbach
    Contributor

    Proposal

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

    Wallet - Once after login, debit card page exits without open

    What is the root cause of that problem?

    The problem is related to the order of actions in DebitCardPage component

    We have two useEffect's

    useEffect(() => {
    PaymentMethods.clearDebitCardFormErrorAndSubmit();
    }, []);
    useEffect(() => {
    if (prevFormDataSetupComplete || !props.formData.setupComplete) {
    return;
    }
    PaymentMethods.continueSetup();
    return () => {
    PaymentMethods.clearDebitCardFormErrorAndSubmit();
    };
    }, [prevFormDataSetupComplete, props.formData.setupComplete]);

    And in the second useEffect the state of the previous and current setupComplete plays a very important role

    When we open this screen for the first time we update the onyx state using the first useEffect what we call PaymentMethods.continueSetup() ahead of time

    As a result, the ref we are using is not ready yet

    And we call this part

        if (!kycWallRef.current?.continue) {
            Navigation.goBack(fallbackRoute);
            return;
        }
    

    And just go back

    function continueSetup(fallbackRoute = ROUTES.HOME) {
    if (!kycWallRef.current?.continue) {
    Navigation.goBack(fallbackRoute);
    return;
    }
    // Close the screen (Add Debit Card, Add Bank Account, or Enable Payments) on success and continue with setup
    Navigation.goBack(fallbackRoute);
    kycWallRef.current.continue();
    }

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

    This problem related to this migrate

    0f0ef68

    Judging by the code, we don’t need clearDebitCardFormErrorAndSubmit when opening the screen

    For this, we call clearDebitCardFormErrorAndSubmit during unmounting

    return () => {
    PaymentMethods.clearDebitCardFormErrorAndSubmit();
    };

    So I think we can remove the first useEffect because I'm not sure it's needed

    But if we are not sure in umounting screen
    We can also add useEffect which calls when we blur the screen

    React.useEffect(() => {
        const unsubscribe = navigation.addListener('blur', () => {
               PaymentMethods.clearDebitCardFormErrorAndSubmit();
      });
    
      return unsubscribe;
    }, [navigation]);
    

    Or

    We can update useEffect which calls only during unmount

    But since we have a call to this function during unmount in another useEffect
    It looks unnecessary

        useEffect(() => {
            return () => {
                PaymentMethods.clearDebitCardFormErrorAndSubmit();
            };
        }, []);
    

    What alternative solutions did you explore? (Optional)

    We can update second useEffect like

    To be sure that kycWallRef.current?.continue is ready

    useEffect(() => {
        if (prevFormDataSetupComplete || !props.formData.setupComplete || !PaymentMethods.kycWallRef.current?.continue) {
            return;
        }
    
        PaymentMethods.continueSetup();
    
        return () => {
            PaymentMethods.clearDebitCardFormErrorAndSubmit();
        };
    }, [prevFormDataSetupComplete, props.formData.setupComplete, !PaymentMethods.kycWallRef.current?.continue]);
    
  9. hungvu193 commented on Oct 20, 2023

    @hungvu193
    Contributor

    Proposal

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

    Once after login, debit card page exits right after opening at start.

    What is the root cause of that problem?

    We only render the KYCWall which included the kycWallRef when user hasWallet:

    {hasWallet && (
    <WalletSection
    icon={Illustrations.MoneyIntoWallet}
    subtitle={translate(`walletPage.${hasActivatedWallet ? 'sendAndReceiveMoney' : 'enableWalletToSendAndReceiveMoney'}`)}
    title={translate('walletPage.expensifyWallet')}
    >
    <>
    {shouldShowLoadingSpinner ? (
    <ActivityIndicator
    color={themeColors.spinner}
    size={CONST.ACTIVITY_INDICATOR_SIZE.LARGE}
    style={[styles.mt7, styles.mb5]}
    />
    ) : (
    <OfflineWithFeedback
    pendingAction={CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}
    errors={walletTerms.errors}
    onClose={PaymentMethods.clearWalletTermsError}
    errorRowStyles={[styles.ml10, styles.mr2]}
    style={[styles.mt7, styles.mb5]}
    >
    <CurrentWalletBalance balanceStyles={[styles.walletBalance]} />
    </OfflineWithFeedback>
    )}
    <KYCWall
    onSuccessfulKYC={(_iouPaymentType, source) => navigateToWalletOrTransferBalancePage(source)}

    That means when user first logging in, kycWallRef was never ready because it was not rendered yet. Later when user entered AddDebitCardPage, a fallback will be called because kycWallRef was not ready, hence !kycWallRef.current?.continue will be true. That's the RCA.

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

    In the past, we will render WalletSection when user has wallet betas here (https://github.com/Expensify/App/pull/26406/files#diff-186ee6dd4f2074460e09890d51b9ef7ef11bc902c32e472b58b76a060a3e4d63)
    However after migrating we decided to only render it when user already had wallet linked.
    I think we should only show the empty state when user doesn't have bank account and assigned card, because we already implemented the Enable Wallet logic for user.
    To do that we should update the shouldShowEmptyState of WalletPage to:

    const hasWalletPer = Permissions.canUseWallet(betas);
    // or just !hasWalletPer &&  !hasBankAccount && !hasAssignedCard;
    const shouldShowEmptyState = !hasWalletPer &&  !hasBankAccount && !hasWallet && !hasAssignedCard;

    What alternative solutions did you explore? (Optional)

    N/A

  10. Pujan92 commented on Oct 20, 2023

    @Pujan92
    Contributor

    Proposal

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

    First time opening a debit card page navigates back

    What is the root cause of that problem?

    It is not reproducible in prod and might be a deploy blocker.
    Seems a regression from #29074 where value for the setupComplete sets to true here in clearDebitCardFormErrorAndSubmit.
    Bcoz of that change this !props.formData.setupComplete will be false and will not return from the below part.

    useEffect(() => {
    if (prevFormDataSetupComplete || !props.formData.setupComplete) {
    return;
    }

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

    We need to make the value for the setupComplete to false in clearDebitCardFormErrorAndSubmit as that is the default value for it.

    function clearDebitCardFormErrorAndSubmit() {
    Onyx.set(ONYXKEYS.FORMS.ADD_DEBIT_CARD_FORM, {
    isLoading: false,
    errors: undefined,
    setupComplete: true,

    Additionally, we can move this cleanup function to correct useEffect block as that will be called on unmount. Currently, it is called each time the dependency updates.

    return () => {
    PaymentMethods.clearDebitCardFormErrorAndSubmit();
    };
    }, [prevFormDataSetupComplete, props.formData.setupComplete]);

    useEffect(() => {
    PaymentMethods.clearDebitCardFormErrorAndSubmit();
    }, []);

  11. 37 remaining items

  12. melvin-bot commented on Nov 2, 2023

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.94-2 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2023-11-09. 🎊

    After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

    • External issue reporter
    • Contributor that fixed the issue
    • Contributor+ that helped on the issue and/or PR

    For reference, here are some details about the assignees on this issue:

  13. melvin-bot commented on Nov 2, 2023

    @melvin-bot

    BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  14. joekaufmanexpensify commented on Nov 6, 2023

    @joekaufmanexpensify
    Contributor

    @parasharrajat could you take care of BZ checklist this week so we can prep to issue payments? TY!

  15. parasharrajat commented on Nov 6, 2023

    @parasharrajat
    Member

    BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

    Regression Test Steps

    1. Logout if logged-in already and then login into the app.
    2. Refresh/reload/restart the app based on the platform.
    3. Goto Settings -> Wallet
    4. Click on Add bank account -> Select debit card option
    5. Verify the screen shows the debit card page properly and doesn't navigate back or refresh on load.

    Do you agree 👍 or 👎 ?

  16. joekaufmanexpensify commented on Nov 8, 2023

    @joekaufmanexpensify
    Contributor

    I am not really convinced we need a regression test for this. When I was triaging this originally, it was actually challenging to do this unless you really knew what to look for. So I don't think this is really worth testing every time. Especially given this was only reproducible the first time after signing in.

  17. joekaufmanexpensify commented on Nov 8, 2023

    @joekaufmanexpensify
    Contributor

    All set to issue payment, as follows:

  18. joekaufmanexpensify commented on Nov 8, 2023

    @joekaufmanexpensify
    Contributor

    @parasharrajat could you please request $500 via NewDot and comment here once complete?

  19. joekaufmanexpensify commented on Nov 9, 2023

    @joekaufmanexpensify
    Contributor

    @dhanashree-sawant $50 sent and contract ended!

  20. joekaufmanexpensify commented on Nov 9, 2023

    @joekaufmanexpensify
    Contributor

    @Pujan92 $500 sent and contract ended!

  21. joekaufmanexpensify commented on Nov 9, 2023

    @joekaufmanexpensify
    Contributor

    Closing as this is all set. All that's left is to pay out @parasharrajat's $500 request. Payment summary message is here.

  22. parasharrajat commented on Dec 5, 2023

    @parasharrajat
    Member

    Payment requested as per #30024 (comment)

  23. JmillsExpensify commented on Dec 11, 2023

    @JmillsExpensify
    Contributor

    $500 payment approved for @parasharrajat based on this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions