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

Add ChooseTransferAccountPage and allow selecting accounts for wallet transfer #7200

Merged
merged 22 commits into from
Jan 24, 2022

Conversation

parasharrajat
Copy link
Member

@parasharrajat parasharrajat commented Jan 13, 2022

Details

Fixed Issues

$ #3922

Tests | QA Steps

  1. Open Payments page.

  2. Click TransferBalance Link.

  3. Confirm that the transfer button is disabled if the following conditions are true.
    i. Transfer Amount is less than $ 0.30.
    ii. Which Account is not selected.

  4. Click instant Mode.

  5. It should take you to the new page where you will select an account. This page should show you Debit cards only and Add Debit Card Button.

  6. Clicking + Add Debit Card Button opens a new page to add Debit Card.

  7. From the Select Account page, click on the any debit card.

  8. You should be taken to the old page where you can see the selected debit card as Which account?

  9. If your balance is > Fee then Transfer Button should be active and it should show the transfer amount - fee.

  10. Click 1-3 Business Days Mode.

  11. It should take you to the new page where you will select an account. This page should show you Bank Accounts only and Add bank account Button.

  12. Clicking + Add bank Account Button opens a new page to add bank Account.

  13. From the Select Account page, click on any bank account.

  14. You should be taken to the old page where you can see the selected bank account card as Which account?

  15. If your balance is > Fee then Transfer Button should be active and it should show the transfer amount - fee.

  16. If your balance is > Fee and which account is set.
    i. Click Transfer button.
    ii. Now you should be taken to the Payments Page and a confirm modal should be shown.

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web | Desktop

output_file.mp4

image

Mobile Web

image image

iOS

Android

image image

@parasharrajat parasharrajat marked this pull request as ready for review January 13, 2022 16:14
@parasharrajat parasharrajat requested a review from a team as a code owner January 13, 2022 16:14
@MelvinBot MelvinBot requested review from stitesExpensify and removed request for a team January 13, 2022 16:14
@parasharrajat
Copy link
Member Author

parasharrajat commented Jan 13, 2022

I didn't do these steps

Create a new component that wraps AddPaymentMethodMenu (without modifying this component too much) and call it “AddBalanceTransferAccountButton”

Create a version of the PaymentMethodList that is selectable. It should not duplicate the logic, but wrap PaymentMethodList.

I used MenuItem directly as there was no need to add Popover and disabled the add Payment method button from the paymentMethodList via a prop. There was no new logic needed for the SelectablePaymentMethodList so I used passed the props to filter the list and show the checkboxes. I don't see any other way of creating a component from PaymentMethodList without passing these props.

@parasharrajat
Copy link
Member Author

cc: @marcaaron

src/libs/actions/PaymentMethods.js Outdated Show resolved Hide resolved
src/libs/actions/PaymentMethods.js Show resolved Hide resolved
src/pages/settings/Payments/ChooseTransferAccountPage.js Outdated Show resolved Hide resolved
src/pages/settings/Payments/ChooseTransferAccountPage.js Outdated Show resolved Hide resolved
src/pages/settings/Payments/TransferBalancePage.js Outdated Show resolved Hide resolved
@parasharrajat
Copy link
Member Author

Updated.

Copy link
Contributor

@stitesExpensify stitesExpensify left a comment

Choose a reason for hiding this comment

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

Testing went pretty well, it's looking good! One bug I found was that when you click add debit card, it always sends you to the add bank account page

src/pages/settings/Payments/ChooseTransferAccountPage.js Outdated Show resolved Hide resolved
@parasharrajat
Copy link
Member Author

Updated @stitesExpensify @marcaaron .

Copy link
Contributor

@stitesExpensify stitesExpensify left a comment

Choose a reason for hiding this comment

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

Code looks pretty good to me. I found 2 more bugs while testing though.

  1. If you have 2 accounts and go to the transfer page, then click the ACH button, neither account is selected even though one was selected on the main page

2022-01-14_13-46-18

  1. If you have a debit card set as your default, it is not shown on the main transfer page

2022-01-14_14-33-38

@parasharrajat
Copy link
Member Author

parasharrajat commented Jan 17, 2022

How can I set the default Payment Method? @stitesExpensify

@stitesExpensify
Copy link
Contributor

The userWallet key in onyx can be manually modified for now to have values like this:

{"availableBalance":12345,"bankAccountID":8,"currentBalance":12345,"currentStep":"","tier":1,"tierName":"SILVER","walletLinkedAccountID":1,"walletLinkedAccountType":"debitCard"}

You can substitute the walletLinkedAccountID and walletLinkedAccountType to be whatever you want to test with

@parasharrajat
Copy link
Member Author

Ok. Fixed both issues.

  1. I was never using the default account on Choose Account screen.
  2. I was using the wrong methodID for debit cards. It should be fundID.

Updated. cc: @stitesExpensify

@stitesExpensify
Copy link
Contributor

I'm still running into some issues while testing. Debit cards seem to work, but if I make a bank account my default the selected account won't change

2022-01-18_18-06-34.mp4

@parasharrajat
Copy link
Member Author

Interesting issue. I can't think of the reason why this is happening but I have two accounts now and I will try to test it.

@parasharrajat
Copy link
Member Author

parasharrajat commented Jan 21, 2022

Finally, fixed. Thanks for catching these issues.

I was doing the wrong matching to get the SelectedAccount. It was picking the Defaultaccount if that comes before in the position the selected account in the payment method Array. Took me some time to figure it out.

Lesson learned: Always criticize your own code.

Ready for review @marcaaron @stitesExpensify

@parasharrajat
Copy link
Member Author

parasharrajat commented Jan 21, 2022

This is ready @marcaaron @stitesExpensify . Sorry for the ping.

@marcaaron
Copy link
Contributor

No worries, but there are guidelines here about when it is appropriate to ping if you need a reminder.

Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

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

Approving since the code is acceptable. Left some non blocking comments and ideas for improvements that can potentially be addressed in follow ups.

: account.fundID,
);
Navigation.navigate(ROUTES.SETTINGS_PAYMENTS_TRANSFER_BALANCE);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB, this method isn't using props so we are redeclaring it on every render. Not that this will make a huge difference performance-wise, but it feels like this is not the correct scope to declare it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I agree but I didn't see any example of such a functional component. Where should I move this. Outside the component in the same file?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah outside the component in the same file would work. Also maybe a good sign that it should be an action instead of a component method.

? account.bankAccountID
: account.fundID,
);
Navigation.navigate(ROUTES.SETTINGS_PAYMENTS_TRANSFER_BALANCE);
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are going back can we just do Navigation.goBack() ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Whatever we do maybe it should be consistent because we are using Navigation.goBack() here

onBackButtonPress={() => Navigation.goBack()}

shouldShowSelectedState
filterType={props.walletTransfer.filterPaymentMethodType}
selectedMethodID={props.walletTransfer.selectedAccountID}
shouldShowAddPaymentMethodButton={false}
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB, but it would be better to eventually find the case where we DO want to show an add payment method button and show one next to the list instead of inside of it. Now we have this list that must specify "no thanks, I don't need this". And in this case we just shows a very similar button below which could be confusing.

Maybe a good follow up issue to create and have someone fix up.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I was thinking th same but then it would unnecessary refactor for this PR so I left it as it is.

PaymentMethods.saveWalletTransferAccountTypeAndID(
selectedAccount.accountType,
selectedAccount.methodID,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB, the more I look at this the more wrong it seems. We are saving data that can be derived from looking at other data and just sort of seems like stuff this component shouldn't be responsible for.

Maybe it says "when I am first loaded then set the most likely default payment method", but I don't think it would be this component's responsibility to filter everything.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that is true. Let me see if I can clean this up bit.

PaymentMethods.saveWalletTransferMethodType(filterPaymentMethodType);
Navigation.navigate(ROUTES.SETTINGS_PAYMENTS_CHOOSE_TRANSFER_ACCOUNT);
}

render() {
const selectedAccount = this.getSelectedPaymentMethodAccount();
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB, feels like we are unnecessarily filtering through all the payment methods to derive this and giving a lot of responsibility to this component.

Copy link
Contributor

Choose a reason for hiding this comment

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

e.g. if we are initializing the payment method type in walletTransfer. accountType and it is based on the value in getSelectedPaymentMethodAccount() then we should be able to just look in walletTransfer? Or no?

Copy link
Member Author

Choose a reason for hiding this comment

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

When we come back from Choose Transfer Account screen. This helps in picking the selected method. Either we should do that in componentDidUpdate or here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I'm not sure that's easy to see or why that would be the case. It maybe works, but the whole interaction between the different sets of data and why we are filtering them on every render is confusing.

Copy link
Contributor

@stitesExpensify stitesExpensify left a comment

Choose a reason for hiding this comment

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

Code looks good, and it tests well! Nice job 😄

@stitesExpensify stitesExpensify merged commit 921fa4f into Expensify:main Jan 24, 2022
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @stitesExpensify in version: 1.1.32-1 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Feb 1, 2022

🚀 Deployed to production by @roryabraham in version: 1.1.33-3 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants