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

Migrate BankAccount_SetupWithdrawalAccount API #3507

Merged
merged 26 commits into from
Jun 15, 2021

Conversation

marcaaron
Copy link
Contributor

@marcaaron marcaaron commented Jun 10, 2021

Details

I tried to keep things familiar here while migrating stuff over from Web-Secure. That means for now, I'm sticking with a single page ReimbursementAccountPage + then conditionally showing views based on the achData.currentStep so basically it's very similar to what we have in Web-Secure.

There are some changes that I am proposing that feel more inline with how we are doing things in Expensify.cash

  • Got rid of the "magic" methods used in Web-Secure used to move between steps, call the withdrawal account API, validate forms, etc. Mostly I found that pattern to be pretty difficult to reason about and the convenience isn't worth the confusion (that's just my opinion, but we don't have any patterns like this in E.cash so far).
  • Instead, every view will handle it's own validation, form state, submit action, and navigation via the header in some cases so nextStep() and previousStep() are no longer triggered in the parent view (addReimbursementPage.jsx in Web-Secure) and instead implemented by each "step". This might be a little more verbose, but I think it's better to be explicit.
  • The country selector in the BankAccountStep is not included since all the accounts added for the free plan should be US.
  • Instead of having a this.achData to reference we are referencing + storing the data for an account in setup in the Onyx cache / localStorage. Most of the logic is left intact, but everywhere we refer to this.achData is now will refer to Onyx data. This is ideal because it eliminates the need for something like ReimbursementAccountPage.refreshView(). Instead we can navigate to the next step simply by setting the Onyx data and letting the view which is subscribing to this data update itself in response.

Fixed Issues (Part 2)

https://github.com/Expensify/Expensify/issues/166041

Tests

  1. Navigate to /add-verified-bank-account
  2. Verify the "Add Bank Account" view appears
  3. Select "Connect Manually"
  4. Enter the test credentials:

Routing Number: 011401533
Account Number: 1111222233331111

  1. Press Save & Continue button
  2. Verify you land on the "Company Information" step
  3. Check the Chrome dev tools Network tab and verify that BankAccount_SetupWithdrawalAccount request was made (Web Only)
  4. Press the "<" button in the top left of the header
  5. Verify you are back on the selection screen
  6. Select "Log Into Your Bank"
  7. Enter the Plaid test credentials

Login: user_good
Password: pass_good

  1. Follow prompts until you reach the account select screen
  2. Select the savings account
  3. Tap Save & Continue button
  4. Verify you land in the "Company Information" step and the API request was successful

QA Steps

No QA necessary until the e2e flow is ready for testing

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

2021-06-11_12-37-38
2021-06-11_12-39-45
2021-06-11_12-39-53
2021-06-11_12-39-53
2021-06-11_12-41-50
2021-06-11_12-42-47
2021-06-11_12-42-55
2021-06-11_12-43-07
2021-06-11_12-43-14

Not including other screenshot because no UI is being added here. The web flow is provided as a reference.

@marcaaron marcaaron self-assigned this Jun 10, 2021
@marcaaron
Copy link
Contributor Author

Trying to get through all of my @TODO notes but so far this is going well and I've got it so we can move from the BankAccountStep > CompanyStep (which is blank for now) but the BankAccount_SetupWithdrawalAccount API is working.

@marcaaron marcaaron changed the title [WIP] Migrate BankAccount_SetupWithdrawalAccount API Migrate BankAccount_SetupWithdrawalAccount API Jun 11, 2021
@marcaaron
Copy link
Contributor Author

Ready for review, but I'm going to run through the rest of the platform testing just to make sure there is nothing unexpected.

@marcaaron marcaaron marked this pull request as ready for review June 11, 2021 22:46
@marcaaron marcaaron requested a review from a team as a code owner June 11, 2021 22:46
@MelvinBot MelvinBot requested review from jasperhuangg and Gonals and removed request for a team June 11, 2021 22:47
@marcaaron marcaaron removed the request for review from Gonals June 11, 2021 22:47
Copy link
Contributor

@NikkiWines NikkiWines left a comment

Choose a reason for hiding this comment

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

Couple of minor comments, overall looking good. Not sure about the TODOs for some of the later account setup steps - esp. the stuff about open bank accounts. I'd like the err on the side of not including it so we don't end up with code we don't need though

}
}

// When going from CompanyStep to BankAccountStep, show the manual form instead of Plaid
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB: When going back to the BankAccountStep from the Company Step just for clarity in the order of the steps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice. Also this is possibly some logic that can be removed.

src/libs/models/BankAccount.js Outdated Show resolved Hide resolved
}

/**
* @deprecated Use !isPending instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

If it's deprecated should we even include it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't really know. Pretty much just copying stuff over from Web-Secure in this case - but probably we can remove any methods that are not used. Might save this for a follow up.

src/pages/ReimbursementAccount/BankAccountStep.js Outdated Show resolved Hide resolved
src/pages/ReimbursementAccount/CompanyStep.js Outdated Show resolved Hide resolved
@marcaaron
Copy link
Contributor Author

I'd like the err on the side of not including it so we don't end up with code we don't need though

I definitely agree with this. However, we have infinite time to follow up and remove things we don't need and not much time to get this done. So, I'm thinking that we can create a follow up issue to address some of these odd @todos and question marks and anything that just generally no longer makes sense.

@marcaaron
Copy link
Contributor Author

Also kind of separate but related - once this flow is nailed down I think it will be a little easier to tell what is needed and what is not so I was a bit hesitant to remove things right away.

src/CONST.js Show resolved Hide resolved
src/languages/es.js Outdated Show resolved Hide resolved
// Only keep allowed parameters in the additionalData object
const additionalData = _.pick(parameters, allowedParameters);

requireParameters(['currentStep'], parameters, commandName);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is another thing we could create a follow-up for, but are there different sets of required parameters for each step? Might be more comprehensible to have something like:

const requiredParameters = [
    CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT: [
        // the required parameters for this step
    ],
    CONST.BANK_ACCOUNT.STEP.COMPANY: [
        // the required parameters for this step
    ],
    ...
    ...
];

And that could help us do better client-side validation 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. I think something like that would clean this up maybe. They are also not used anywhere else atm.

src/libs/actions/BankAccounts.js Outdated Show resolved Hide resolved
src/libs/actions/BankAccounts.js Show resolved Hide resolved
);
const sdkToken = lodashGet(onfidoRes, CONST.BANK_ACCOUNT.ONFIDO_RESPONSE.SDK_TOKEN);
if (sdkToken && !previousACHData.isOnfidoSetupComplete
&& onfidoRes.status !== CONST.BANK_ACCOUNT.ONFIDO_RESPONSE.PASS
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
&& onfidoRes.status !== CONST.BANK_ACCOUNT.ONFIDO_RESPONSE.PASS
&& onfidoRes.status !== CONST.BANK_ACCOUNT.ONFIDO_RESPONSE.PASS)

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, should this really be using || instead of && ?

if (sdkToken
    || !previousACHData.isOnfidoSetupComplete
    || onfidoResponse.status !== CONST.BANK_ACCOUNT.ONFIDO_RESPONSE.PASS) {
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure. Why should it?

src/libs/actions/BankAccounts.js Show resolved Hide resolved
src/libs/actions/BankAccounts.js Show resolved Hide resolved
src/libs/actions/BankAccounts.js Outdated Show resolved Hide resolved
Copy link
Contributor Author

@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.

Thanks for the review @roryabraham!

src/libs/actions/BankAccounts.js Outdated Show resolved Hide resolved
src/libs/actions/BankAccounts.js Outdated Show resolved Hide resolved
src/libs/actions/BankAccounts.js Outdated Show resolved Hide resolved
src/libs/actions/BankAccounts.js Outdated Show resolved Hide resolved
src/libs/actions/BankAccounts.js Show resolved Hide resolved
src/libs/actions/BankAccounts.js Show resolved Hide resolved
src/libs/actions/BankAccounts.js Outdated Show resolved Hide resolved
src/libs/actions/BankAccounts.js Show resolved Hide resolved
src/libs/actions/BankAccounts.js Show resolved Hide resolved
src/libs/actions/BankAccounts.js Show resolved Hide resolved
src/libs/actions/BankAccounts.js Outdated Show resolved Hide resolved
jasperhuangg
jasperhuangg previously approved these changes Jun 15, 2021
Copy link
Contributor

@NikkiWines NikkiWines left a comment

Choose a reason for hiding this comment

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

Looks good! One tiny comment.

I also noticed that I wasn't getting routed to the Company Step ever, I just get re-routed to the beginning of the add VBA flow.

Edit: NVM turns out I set up a VBA with those values already which is why it was re-routing incorrectly 🙃 I retested on a different account and everything works as expected

src/libs/actions/BankAccounts.js Outdated Show resolved Hide resolved
@marcaaron
Copy link
Contributor Author

@NikkiWines I think it's because there are errors - going to swap out the console.error for a growl instead so it's more obvious something went wrong.

Copy link
Contributor

@NikkiWines NikkiWines left a comment

Choose a reason for hiding this comment

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

Looks good! The growl is definitely way clearer 👍
Screen Shot 2021-06-15 at 11 18 24 AM

function goToWithdrawalAccountSetupStep(stepID, achData) {
const newACHData = {...previousACHData};

// If we go back to Requestor Step, reset any validation and previously answered questions from expectID.
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB: When going to the Requestor Step, reset any validation and previously answered questions from expectID.

@shawnborton
Copy link
Contributor

Looks like the icon colors are off in this screenshot:
image

I think they should be in our standard colors.icon which is like a gray

@marcaaron
Copy link
Contributor Author

Will do a follow up for the icon colors @shawnborton

Spoke with @ctkochan22 who gave this a once over and mentioned not blocking on him so I'm going to merge this to keep things moving.

@marcaaron marcaaron merged commit c1b4bd4 into main Jun 15, 2021
@marcaaron marcaaron deleted the marcaaron-setupWithdrawlAccount branch June 15, 2021 18:46
@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 in version: 1.0.69-1🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production in version: 1.0.73-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.

6 participants