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

[$125] Wallet - No "Make default payment method" option after adding 2nd account #52641

Open
2 of 8 tasks
lanitochka17 opened this issue Nov 15, 2024 · 8 comments
Open
2 of 8 tasks
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 Help Wanted Apply this label when an issue is open to proposals by contributors Overdue

Comments

@lanitochka17
Copy link

lanitochka17 commented Nov 15, 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: 9.0.63
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Issue reported by: Applause - Internal Team

Issue found when executing PR #51437

Action Performed:

  1. Log in to the account that has no bank accounts
  2. Navigate to Settings > Wallet and click on Add Bank Account > Personal Bank Account
  3. On the Plaid modal, search and select Wells Fargo bank, enter credentials (e.g., user_good / pass_good), and complete the process
  4. Verify that the added bank account is not marked as the default (because we are not showing default badge if there is only one bank account)
  5. Repeat the process to add a second bank account by selecting Chase bank

Expected Result:

The "Make default payment method" option is displayed in the three-dot menu of the first bank account added without needing a page refresh

Actual Result:

The "Make default payment method" option is not displayed in the three-dot menu of the first bank account added after adding 2nd account. A page refresh is needed to display the option

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
Bug6666585_1731691611157.51437-mWeb.mp4

Bug6666585_1731691611180!Make_default_payment_method_-_After_refreshing

No_refresh

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021857547420122900843
  • Upwork Job ID: 1857547420122900843
  • Last Price Increase: 2024-11-15
Issue OwnerCurrent Issue Owner: @thesahindia
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Nov 15, 2024
Copy link

melvin-bot bot commented Nov 15, 2024

Triggered auto assignment to @joekaufmanexpensify (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.

@joekaufmanexpensify
Copy link
Contributor

Reproduced

@joekaufmanexpensify joekaufmanexpensify added the External Added to denote the issue can be worked on by a contributor label Nov 15, 2024
@melvin-bot melvin-bot bot changed the title Wallet - No "Make default payment method" option after adding 2nd account [$250] Wallet - No "Make default payment method" option after adding 2nd account Nov 15, 2024
Copy link

melvin-bot bot commented Nov 15, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Nov 15, 2024
@joekaufmanexpensify joekaufmanexpensify moved this to Bugs and Follow Up Issues in [#whatsnext] #expense Nov 15, 2024
Copy link

melvin-bot bot commented Nov 15, 2024

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

@joekaufmanexpensify
Copy link
Contributor

Pretty minor bug, so adjusting price

@joekaufmanexpensify joekaufmanexpensify changed the title [$250] Wallet - No "Make default payment method" option after adding 2nd account [$125] Wallet - No "Make default payment method" option after adding 2nd account Nov 15, 2024
Copy link

melvin-bot bot commented Nov 15, 2024

Upwork job price has been updated to $125

@Shahidullah-Muffakir
Copy link
Contributor

Shahidullah-Muffakir commented Nov 15, 2024

Edited by proposal-police: This proposal was edited at 2024-11-15 22:56:19 UTC.

Proposal

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

The "Make default payment method" button is not appearing when a second payment method is added until the page is refreshed.

What is the root cause of that problem?

const shouldShowMakeDefaultButton = !paymentMethod.isSelectedPaymentMethodDefault;

This logic is insufficient because isSelectedPaymentMethodDefault remains true for previous default payment method, when we add a new payment method, until we refresh the page and the OpenPaymentsPage, fetch the updated data.

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

we can add the same check here, as I added in my last PR here:#51437
we need to use walletLinkedAccountID, and if for the selectedPaymentMethod isSelectedPaymentMethodDefault is true but its account id does not match walletLinkedAccountID, then we should show Make default payment method

we can use this check :

    const isMarkedDefaultButNotMostRecent = ()=>{
        
        if(paymentMethod.formattedSelectedPaymentMethod.type === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT ){
           return paymentMethod.selectedPaymentMethod.bankAccountID !== userWallet?.walletLinkedAccountID && paymentMethod.isSelectedPaymentMethodDefault;
        }
        if(paymentMethod.formattedSelectedPaymentMethod.type === CONST.PAYMENT_METHODS.DEBIT_CARD){
            return paymentMethod.selectedPaymentMethod.fundID !== userWallet?.walletLinkedAccountID && paymentMethod.isSelectedPaymentMethodDefault;
        }
    }

update the condition:

const shouldShowMakeDefaultButton = !paymentMethod.isSelectedPaymentMethodDefault;

as:

const shouldShowMakeDefaultButton =
     (!paymentMethod.isSelectedPaymentMethodDefault || isMarkedDefaultButNotMostRecent()) &&
     !(paymentMethod.formattedSelectedPaymentMethod.type === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT && paymentMethod.selectedPaymentMethod.type === CONST.BANK_ACCOUNT.TYPE.BUSINESS);

@nkdengineer
Copy link
Contributor

Proposal

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

The "Make default payment method" option is not displayed in the three-dot menu of the first bank account added after adding 2nd account. A page refresh is needed to display the option

What is the root cause of that problem?

The condition to show the Default badge and the condition to show Make default payment method are different

  1. The condition to show the Default badge is based on shouldShowDefaultBadge which will return the most recent default method

shouldShowDefaultBadge(

  1. While the condition to show the Make default payment method is based on paymentMethod.isDefault which can be wrong after we add the 2nd account. The context can see here
    paymentMethod.isDefault,

isSelectedPaymentMethodDefault: !!isDefault,

const shouldShowMakeDefaultButton =
!paymentMethod.isSelectedPaymentMethodDefault &&
!(paymentMethod.formattedSelectedPaymentMethod.type === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT && paymentMethod.selectedPaymentMethod.type === CONST.BANK_ACCOUNT.TYPE.BUSINESS);

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

We should also use shouldShowDefaultBadge function to check if this paymentMethod is default or not

const finalCombinedPaymentMethods = combinedPaymentMethods.map((paymentMethod) => {
    const isMethodActive = isPaymentMethodActive(actionPaymentMethodType, activePaymentMethodID, paymentMethod);
    const isDefault = shouldShowDefaultBadge(
        combinedPaymentMethods,
        paymentMethod,
        userWallet?.walletLinkedAccountID ?? 0,
        invoiceTransferBankAccountID ? invoiceTransferBankAccountID === paymentMethod.methodID : paymentMethod.isDefault,
    );
    return {
        ...paymentMethod,
        onPress: (e: GestureResponderEvent) =>
            onPress(
                ...
                isDefault,
                paymentMethod.methodID,
            ),
        ...
    };
});
return finalCombinedPaymentMethods;

paymentMethod.isDefault,

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Nov 18, 2024
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 Help Wanted Apply this label when an issue is open to proposals by contributors Overdue
Projects
Status: Bugs and Follow Up Issues
Development

No branches or pull requests

5 participants