Skip to content

Add ChooseTransferAccountPage and allow selecting accounts for wallet transfer#7200

Merged
stitesExpensify merged 22 commits into
Expensify:mainfrom
parasharrajat:trans-amount-scaffold
Jan 24, 2022
Merged

Add ChooseTransferAccountPage and allow selecting accounts for wallet transfer#7200
stitesExpensify merged 22 commits into
Expensify:mainfrom
parasharrajat:trans-amount-scaffold

Conversation

@parasharrajat

@parasharrajat parasharrajat commented Jan 13, 2022

Copy link
Copy Markdown
Member

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

parasharrajat commented Jan 13, 2022

Copy link
Copy Markdown
Member Author

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
Copy Markdown
Member Author

cc: @marcaaron

Comment thread src/libs/actions/PaymentMethods.js Outdated
Comment thread src/libs/actions/PaymentMethods.js
Comment thread src/pages/settings/Payments/ChooseTransferAccountPage.js Outdated
Comment thread src/pages/settings/Payments/ChooseTransferAccountPage.js Outdated
Comment thread src/pages/settings/Payments/TransferBalancePage.js
Comment thread src/pages/settings/Payments/TransferBalancePage.js Outdated
@parasharrajat

Copy link
Copy Markdown
Member Author

Updated.

Comment thread src/libs/actions/PaymentMethods.js Outdated

@stitesExpensify stitesExpensify left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread src/pages/settings/Payments/ChooseTransferAccountPage.js Outdated
@parasharrajat

Copy link
Copy Markdown
Member Author

Updated @stitesExpensify @marcaaron .

@stitesExpensify stitesExpensify left a comment

Copy link
Copy Markdown
Contributor

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

parasharrajat commented Jan 17, 2022

Copy link
Copy Markdown
Member Author

How can I set the default Payment Method? @stitesExpensify

@stitesExpensify

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

parasharrajat commented Jan 21, 2022

Copy link
Copy Markdown
Member Author

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

parasharrajat commented Jan 21, 2022

Copy link
Copy Markdown
Member Author

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

@marcaaron

Copy link
Copy Markdown
Contributor

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

@marcaaron marcaaron left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

}

render() {
const selectedAccount = this.getSelectedPaymentMethodAccount();

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@stitesExpensify stitesExpensify left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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

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

@OSBotify

OSBotify commented Feb 1, 2022

Copy link
Copy Markdown
Contributor

🚀 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