Add Pattern B to creating Personal Bank Account#10953
Conversation
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
|
To do:
|
| const selectedPlaidBankAccount = lodashGet(this.props, 'plaidData.selectedPlaidBankAccount', {}); | ||
| const {icon, iconSize} = getBankIcon(); | ||
|
|
||
| // Show selected plaid bank account. If not set, check the props to see if we have one pre-selected |
There was a problem hiding this comment.
when does that happen? Also, did you mean state instead of props?
There was a problem hiding this comment.
Well the state of AddPersonalBankAccountPage, but it's being passed into here as a prop.
There was a problem hiding this comment.
Sorry I'm still trying to wrap my mind around the merge with your PR.
So when you select an account here, we set the state in AddPersonalBankAccount. I wanted to keep the bank account we selected when the user navigate back to the form.
There was a problem hiding this comment.
Then let's just pass selectedPlaidAccountID via props (add add it to the propTypes)
There was a problem hiding this comment.
Oh I just realized there is a bug (minor edge case) where this all gets messed up if someone is setting up a VBA (using BankAccounts.updatePlaidData) and also setting up a PBA.
- Try to create a PBA.
- Login into plaid, then selecting the test account that ends with
000. Add an incorrect password and submit (creates a pending PBA) - Now go to your workspace settings. Choose "Connect bank account" to setup VBA. Log into plaid
- Selected the bank account
1111. - Navigate bank to the PBA, it will be set to
1111. - Click
0000, go to next tab, the state forced it back to1111. We just need to run update here too
There was a problem hiding this comment.
We can just continue to use updatePlaidData here too?
| setDefaultFailure: 'Something went wrong. Please chat with Concierge for further assistance.', | ||
| }, | ||
| addBankAccountFailure: 'And unexpected error occurred while trying to add your bank account. Please try again.', | ||
| addBankAccountFailure: 'An unexpected error occurred while trying to add your bank account. Please try again.', |
|
Updated |
|
Updated please review again! 🙇 |
| return {}; | ||
| } | ||
|
|
||
| // Get errors |
There was a problem hiding this comment.
Why are we reformatting the errors here?
There was a problem hiding this comment.
This is how we use to. How do we pass back errors now? Atm we don't seem to pass back any errors within the item itself.
We pass errors back in timestamp => errorMessage format, but the item object takes an array of error messages
There was a problem hiding this comment.
Sorry, I don't think I'm following the logic in this function. So we're basically fetching the personalBankAccount currently being setup, taking the errors and adding it to pendingBankAccount (retrieved from the Plaid data). And we're doing this because we need some additional properties like the account number, address name, etc. in formatPaymentMethods. Is that right?
Perhaps an alternative here would be to take the properties we need from pendingBankAccount and add them to personalBankAccount instead. So we won't have to do any reformatting of the errors. Not a major win but maybe would make this more understandable?
There was a problem hiding this comment.
Ah, so we have bank account info in plaidData. Stuff like unmasked account numbers and such. Data we need to pass to PHP when trying to add a bank account.
Currently, when you try to add a bank account, we let the data sit in plaidData and just save selectePlaidAccountID in the onyxkey personalBankAccount. We currently use that to find the bank account they selected in plaidData. And we then format that data so that it would appear in the payment list.
You are suggesting that upon submission, we save data we need, formatted already, into personalBankAccount. So when we show the payment methods, we don't have to do anything here.
I'm good with that. My argument against that is, we would be doing some sort of "massaging" somewhere in the client side, because its client side data. So instead of doing all the formatting and such here, we'd do it in BankAccounts.addPersonalBankAccount. It may make this method cleaner, but still somewhat convoluted? And I think it'll make it harder to follow.
There was a problem hiding this comment.
Thanks for clarifying! I like your suggestion:
So instead of doing all the formatting and such here, we'd do it in `BankAccounts.addPersonalBankAccount`
I think perhaps the flow would be easier to understand if we did the above. Would something like this work:
- The user submits the add bank account form
- We fetch the all we need from
plaidDataand store it in thepersonalBankAccountkey - We can display the pending bank account in the payment methods list without needing any more formatting in
formatPaymentMethods(...)
| // See if we need to show a pending bank account in the payment methods list | ||
| if (!_.isEmpty(pendingBankAccount)) { |
There was a problem hiding this comment.
Is this data massaging something we can do in OpenPaymentsPage instead?
There was a problem hiding this comment.
I don't think so. This pending bank account is all local data. None of this is stored on the server-side. Just like plaid data
There was a problem hiding this comment.
Is this data massaging? Something can be empty or undefined.
There was a problem hiding this comment.
Is this data massaging?
Ah, sorry, I wasn't clear. I meant the data massaging on lines 43 - 54.
But if this data is all local data then I don't see how we can avoid this 🤔
You mean when they submit offline. We could, although I feel like we common practice is to keep them there? We give them the option to navigate away, but what if they only lost connection for a second? It would be annoying to be navigated away when you are a second away from getting feedback |
| // See if we need to show a pending bank account in the payment methods list | ||
| if (!_.isEmpty(pendingBankAccount)) { |
There was a problem hiding this comment.
Is this data massaging?
Ah, sorry, I wasn't clear. I meant the data massaging on lines 43 - 54.
But if this data is all local data then I don't see how we can avoid this 🤔
| return {}; | ||
| } | ||
|
|
||
| // Get errors |
There was a problem hiding this comment.
Sorry, I don't think I'm following the logic in this function. So we're basically fetching the personalBankAccount currently being setup, taking the errors and adding it to pendingBankAccount (retrieved from the Plaid data). And we're doing this because we need some additional properties like the account number, address name, etc. in formatPaymentMethods. Is that right?
Perhaps an alternative here would be to take the properties we need from pendingBankAccount and add them to personalBankAccount instead. So we won't have to do any reformatting of the errors. Not a major win but maybe would make this more understandable?
That's an interesting point. Maybe just my perspective but if I was offline and saw the whole form go blank, it wouldn't be clear what was happening. If I was redirected to the payment methods page showing the bank account greyed out, it would be clear that it's pending creation. |
|
Okay, we are close. I can feel it! Issue: We want to avoid all the massaging here.
This is the solution @MariaHCD and I agreed on. Can you take a look and let us know your thoughts so we are on the same page? |
|
That approach makes sense to me.
Perhaps we can have ^ set in the optimisticData here. |
Alternate proposal for pattern B of AddPersonalBankAccount




cc @MariaHCD @nkuoch
Details
We are adding pattern b to creating a Personal Bank Account.
Hold https://github.com/Expensify/Web-Expensify/pull/34855
Features:
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/214739
Tests
Same as QA
PR Review Checklist
Contributor (PR Author) Checklist
### Fixed Issuessection aboveTestssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*filesSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */displayNamepropertythisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)PR Reviewer Checklist
The Contributor+ will copy/paste it into a new comment and complete it after the author checklist is completed
### Fixed Issuessection aboveTestssectionQA stepssectiontoggleReportand notonIconClick).src/languages/*filesSTYLE.md) were followedAvatar, I verified the components usingAvatarhave been tested & I retested again)/** comment above it */displayNamepropertythisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)QA Steps
Basic flow
user_good,pass_good,credential_good(if they ask for a code)Test Offline Behavior
Pick up where you left off last section
Type in an incorrect password
Before submitting, go offline.
Submit. Verify that everything is greyed out

Go back online and verify that the error still comes up.
Go back offline and submit again.
Now navigate away from the modal (or close it).
Then go back online, and verify that you see a red brick indicator come up.

Avatar:
Payments menu item

Red brick near the pending bank account

Now click on the pending bank account and then verify that you see the error on the form
Now go back offline.
Type in the correct password
Go offline and then submit.
Navigate away. Then go back online
Go to payments page and verify that the new bank account has been added.
Screenshots
Web
Mobile Web
Desktop
iOS
Android