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

[Refactor] Use new API Command: UpdateBeneficialOwnersForBankAccount #10994

Merged
merged 20 commits into from
Oct 17, 2022

Conversation

NikkiWines
Copy link
Contributor

@NikkiWines NikkiWines commented Sep 14, 2022

Details

Associated web PR: https://github.com/Expensify/Web-Expensify/pull/34853

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/226855

Tests

  • Verify that no errors appear in the JS console

PR Review Checklist

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

PR Reviewer Checklist

The reviewer will copy/paste it into a new comment and complete it after the author checklist is completed

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

QA Steps

  1. In NewExpensify log into an account with a workspace / Create an account and then create a workspace
  2. Navigate to Settings > Workspace > Connect Bank Account
  3. Follow the steps from this StackOverflow post to add a verifying bank account
  4. Confirm that after submitting the beneficial owners step that you are routed to the Validate Bank Account - Let's finish in chat page

Screen Shot 2022-10-17 at 4 23 46 PM

Screenshots

Web

Pending:

pending.mov

Verifying:

verifying.mov

Open

Screen.Recording.2022-10-05.at.14.54.06.mov

Desktop

desktop-pending.mov

mWeb

mweb-pending.mp4

iOS

ios-pending.mp4

Android

android-pending.webm

@NikkiWines NikkiWines self-assigned this Sep 14, 2022
@NikkiWines NikkiWines marked this pull request as ready for review September 23, 2022 15:12
@NikkiWines NikkiWines requested a review from a team as a code owner September 23, 2022 15:12
@melvin-bot melvin-bot bot requested review from sketchydroide and removed request for a team September 23, 2022 15:13
@NikkiWines
Copy link
Contributor Author

Oops, sorry @sketchydroide - please hold off reviewing for now, this isn't quite ready

@NikkiWines NikkiWines changed the title [HOLD][Refactor] Use new API Command: UpdateBeneficialOwnersForBankAccount [HOLD 34853][Refactor] Use new API Command: UpdateBeneficialOwnersForBankAccount Sep 23, 2022
@nkuoch
Copy link
Contributor

nkuoch commented Sep 26, 2022

#11162 has been merged on main - please merge main on your branch

@MariaHCD MariaHCD self-requested a review October 5, 2022 07:52
Copy link
Contributor

@MariaHCD MariaHCD left a comment

Choose a reason for hiding this comment

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

LGTM! We'll just need the test steps and QA steps added for this one

MariaHCD
MariaHCD previously approved these changes Oct 6, 2022
sketchydroide
sketchydroide previously approved these changes Oct 6, 2022
Copy link
Contributor

@sketchydroide sketchydroide left a comment

Choose a reason for hiding this comment

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

LGTM

@sketchydroide
Copy link
Contributor

Do we need to add C+?

@NikkiWines
Copy link
Contributor Author

@sketchydroide I don't think it has to be a C+ to do the PR reviewer checklist, any reviewer should be able to check things so that the test passes?

@JmillsExpensify
Copy link

We've been talking about this topic in this #whatsnext post. As a quick summary, this is what's being proposed as the new standard:

  • PRs that change code that runs in any of our platforms must have screenshots/videos (proof of testing) for all platforms (same as today for contributors, but a new standard for us)
  • Both checklists (author & reviewer) must be filled out on all PRs (same as today for contributors, but a new standard for us)
  • C+ is assigned to all PRs (same as today for contributors, but a new standard for us)

@MariaHCD
Copy link
Contributor

  1. Testing on the iOS simulator

@NikkiWines Have you tested checking the boxes for I own more than 25%.. and/or Somebody else owns more than 25%...? I checked those boxes for an OPEN bank account and landed on an empty ValidationStep page:

Screen.Recording.2022-10-11.at.4.44.34.PM.mov

I also tried the flow without checking those two boxes and still ended up on an empty ValidationStep page 😕

I also get this error pop up during the setup process (but I don't think it's related to this PR) 🤔

Simulator Screen Shot - iPhone 14 - 2022-10-11 at 16 40 15

Simulator Screen Shot - iPhone 14 - 2022-10-11 at 16 51 34

@MariaHCD
Copy link
Contributor

  1. Testing on MacOS / Chrome

Hmm, getting an error after selecting a Plaid bank account. Also doesn't seem related to this PR 🤔

Screen Shot 2022-10-11 at 5 44 52 PM

@NikkiWines
Copy link
Contributor Author

@NikkiWines Have you tested checking the boxes for I own more than 25%.. and/or Somebody else owns more than 25%...? I checked those boxes for an OPEN bank account and landed on an empty ValidationStep page:

Also able to reproduce this on Web - digging into it now.

I also tried the flow without checking those two boxes and still ended up on an empty ValidationStep page 😕

Weird, I'm getting this now too but it was definitely working before 🤔

Hmm, getting an error after selecting a Plaid bank account. Also doesn't seem related to this PR 🤔

I'm also getting these now - maybe some new code merged to main?

@NikkiWines
Copy link
Contributor Author

It looks like for the Uncaught TypeError: Cannot set properties of undefined (setting 'bankName') error is because onInputChange is getting called twice in a row and the second time doesn't have any value associated with it. Potentially tied to this PR which was merged a couple days ago

@NikkiWines
Copy link
Contributor Author

For the blank validationStep flows it looks like using the Wells Fargo creds and following the SO post is returning the bank account in state SETUP? No idea what would've caused that regression but will continue digging.

@NikkiWines
Copy link
Contributor Author

@MariaHCD it seems to be an issue with useOnfido being true even when we're using the Wells Fargo credentials and skipping the onFido step. Because it's being passed as true we end up filtering out requestorIdentityKBA from the additionalData being passed to SetupWithdrawalAccount.cpp.

When checking the logs I can see we're successfully passing it originally but then there's an error saying it's missing from externalAPIResponses and the bank account state reverts to SETUP.

rJ6WYG /api.php nikki@meep.com !ecash1.2.12-3! ?api? [info] Bedrock\Client - Starting a request ~~ command: 'SetupWithdrawalAccount' clusterName: 'auth' headers: '[authToken: '<REDACTED>' additionalData: '[routingNumber: '011401533' accountNumber: '<REDACTED>' addressName: 'Alberta Bobbeth Charleson' isSavings: '1' bankAccountID: '1179234' created: '2022-10-11 14:01:09' state: 'SETUP' acceptTerms: '1' addressCity: 'San Francisco' addressState: 'CA' addressStreet: 'Test Street' addressZipCode: '94103' bankName: '' beneficialOwners: '[]' companyName: 'Alberta Bobbeth Charleson' companyPhone: '1234567890' companyTaxID: '123456789' country: 'US' currency: 'USD' currentStep: 'ACHContractStep' dateSigned: '2022-10-11 20:57:01' dob: '1998-01-01' enableCardAfterVerified: '1' fieldsType: 'local' firstName: 'Alberta' hasFullSSN: '1' hasNoConnectionToCannabis: '1' incorporationDate: '2001-01-01' incorporationState: 'AK' incorporationType: 'LLC' industryCode: '541930' isControllingOfficer: '1' lastName: 'Charleson' lastUpdate: '2022-10-11 20:38:18' ownsMoreThan25Percent: '' plaidAccountID: 'E1MqdJWGnEF4wpEjmwWJTl7PJekGakFvpW8NX' previousState: '2' requestorAddressCity: 'San Francisco' requestorAddressState: 'CA' requestorAddressStreet: 'Test Street' requestorAddressZipCode: '94103' setupType: 'plaid' ssnLast4: '2034' useOnfido: '1' verifications: '[externalApiResponses: '[bankAccount: '[apiResult: '[reason: 'Plaid test withdrawal account']' status: 'pass' timestamp: '2022-10-11 18:34:11']' companyTaxID: '[apiResult: '[reason: 'Plaid test withdrawal account']' status: 'pass' timestamp: '2022-10-11 18:34:11']' lexisNexisInstantIDResult: '[apiResult: '[reason: 'Plaid test withdrawal account']' status: 'pass' timestamp: '2022-10-11 18:34:11']' realSearchResult: '[apiResult: '[reason: 'Plaid test withdrawal account']' status: 'pass' timestamp: '2022-10-11 18:34:11']' requestorIdentityID: '[apiResult: '[reason: 'Plaid test withdrawal account']' status: 'pass' timestamp: '2022-10-11 18:34:24']' requestorIdentityOnfido: '[apiResult: '[reason: 'Plaid test withdrawal account']' status: 'pass' timestamp: '2022-10-11 18:34:24']' requestorIdentityKBA: '[status: 'pass' apiResult: '[reason: 'Tested via Onfido instead']' timestamp: '2022-10-11 20:57:01']']']' website: 'https://www.meep.com']' isFromVerifyBankTool: '' bankAccountID: '1179234' logParam: 'nikki@meep.com' commitCount: '4148' requestID: 'rJ6WYG' lastIP: '62.195.76.50' writeConsistency: 'ASYNC' priority: '500' timeout: '290000']'
...
rJ6WYG nikki@meep.com (BankAccount.cpp:1882) getFilteredAdditionalDataJSON [socket9] [info] Calling SetupWithdrawalAccount for step ACHContractStep using onfido
...
rJ6WYG nikki@meep.com (BankAccount.cpp:2388) isSetupComplete [socket9] [info] Setup is not complete because externalAPIResponses['requestorIdentityKBA'] is missing
....
rJ6WYG nikki@meep.com (BankAccount.cpp:2007) setupWithdrawalAccount [socket9] [info] [audit] Setting up withdrawal account for accountID 4 (bankAccountID 1179234, state 4)

Using an ssn of 3333 seems to bypass the issue, allowing us to set up the VBBA successfully in the OPEN state when using Wells Fargo creds. Not sure why useOnFido is being set to true, but looking into it more now.

Copy link
Contributor

@MariaHCD MariaHCD left a comment

Choose a reason for hiding this comment

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

@NikkiWines Thanks for investigating that! It's probably due to this fix for VerifyIdentityForBankAccount: https://github.com/Expensify/Web-Expensify/pull/35108

We started sending useOnfido as true for every step in the flow here. And we actually don't need requestorIdentityKBA anymore. It used to be a fallback to Onfido but we removed this fallback for NewDot (more details here)

So it sounds like we just need to understand when Onfido can be skipped and when it cannot.

cc: @nkuoch

@JmillsExpensify
Copy link

Question question: with 34853 merged and now on production can we remove the [HOLD] on this PR?

@NikkiWines NikkiWines changed the title [HOLD 34853][Refactor] Use new API Command: UpdateBeneficialOwnersForBankAccount [Refactor] Use new API Command: UpdateBeneficialOwnersForBankAccount Oct 12, 2022
@MariaHCD
Copy link
Contributor

MariaHCD commented Oct 12, 2022

We still need to work through a small issue with the flow: #10994 (comment)

I'm looking into it!

@MariaHCD
Copy link
Contributor

Looks like we get the error (BankAccount.cpp:2385) isSetupComplete [socket298] [info] Setup is not complete because externalAPIResponses['requestorIdentityKBA'] is missing because useOnfido is false here (the bank account's additionalData does not have the onfidoData)

I'm not 100% sure of why/when we skip Onfido during the VBBA flow, I can dig into it more tomorrow

@MariaHCD
Copy link
Contributor

Made sure to pull the latest changes from Auth and the tests work better today 🎊

  1. iOS / native
Screen.Recording.2022-10-13.at.4.29.45.PM.mov
  1. Android / native
Screen.Recording.2022-10-13.at.6.30.20.PM.mov
  1. iOS / Safari
Screen.Recording.2022-10-13.at.4.42.08.PM.mov
  1. Android / Chrome
XRecorder_13102022_184043.mp4
  1. MacOS / Chrome
2.New.Expensify.webm
  1. MacOS / Desktop
Screen.Recording.2022-10-13.at.5.06.52.PM.mov
Screen.Recording.2022-10-13.at.5.08.54.PM.mov

@MariaHCD
Copy link
Contributor

But unfortunately, I'm still running into that blank Validation page when adding an OPEN bank account:

Screen Shot 2022-10-11 at 4 29 29 PM

Testing this PR and the web deploy took up a lot of my time today so will have to take a look at this tomorrow.

@NikkiWines
Copy link
Contributor Author

Thanks for all the testing @MariaHCD!! Went through it again myself and got the same results as you.

It looks like things may have just changed with https://github.com/Expensify/Auth/pull/7091 just getting merged but to recap this is why the OPEN VBBA flow is routing to the SETUP state instead of OPEN.

TLDR; we need to make sure useOnfido is defined by the same check in getFilteredAdditionalDataJSON() here and in isSetupComplete() here. Right now that bool true in getFilteredAdditionalDataJSON() but false in isSetupComplete() - which results in our error and bad setup state.

Long explanation

We pass along both useOnfido: '1' and requestorIdentityKBA: '[status: 'pass' apiResult: '[reason: 'Tested via Onfido instead']' in the additional data when calling the SetupWithdrawalAccount command (when setting up with the Wells Fargo Plaid creds)

In getFilteredAdditionalDataJSON() we define const bool useOnfido based only on if useOnfido is true or not when it's passed to the command. In that function we call getRequiredVerificationSetupAttributes() which takes in useOnfido. Because useOnfido is true at this point, our step name to use is ACHContractStepWithOnfido which returns nothing for our required setup attributes.

This results in us leaving out requestorIdentityKBA from the externalApiResponses that we add to the additionalDataJSON.

Then, later in isSetupComplete(), const bool useOnfido is based off of both useOnfido being true, and onfidoData being passed (as @MariaHCD mentioned here. Because we're not passing onfidoData, useOnfido is now false and our step name to use is ACHContractStep returns an requestorIdentityKBA as a key for our required setup attributes. Since that's now required - we end up failing and returning here leaving our bank account in state setup.

@JmillsExpensify
Copy link

Quick question: Are we holding on this PR until the Auth PR for consistently handling Onfido is merged?

@MariaHCD
Copy link
Contributor

Thinking about @JmillsExpensify's comment, I think we can merge this PR. The bug with the flow is on the backend. I've created a separate issue to investigate and fix that: https://github.com/Expensify/Expensify/issues/234337

@MariaHCD MariaHCD merged commit 26e0618 into main Oct 17, 2022
@MariaHCD MariaHCD deleted the nikki-refactor-beneficial-owners branch October 17, 2022 12:24
@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.

@JmillsExpensify
Copy link

Nice, agree with that. Thanks all!

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @MariaHCD in version: 1.2.17-0 🚀

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

@roryabraham
Copy link
Contributor

Hi everyone 👋🏼

It seems like this PR is the most likely culprit for this deploy blocker. Would be great if anyone with context on the changes in this PR could look into that 🙇🏼

@MariaHCD
Copy link
Contributor

It seems like this PR is the most likely culprit for this deploy blocker. Would be great if anyone with context on the changes in this PR could look into that 🙇🏼

This is likely a backend error and not a frontend error. We're investigating here: https://github.com/Expensify/Expensify/issues/234337

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @sketchydroide in version: 1.2.17-4 🚀

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.

8 participants