App icon indicating copy to clipboard operation
App copied to clipboard

Feat: Add a step to to Request Physical Card form that collects a magic code

Open hungvu193 opened this issue 1 year ago • 10 comments

Details

This PR added a validate code modal when user want to issue a physical card.

Fixed Issues

$ https://github.com/Expensify/App/issues/50967 PROPOSAL: N/A

Tests

Prerequisite: Your account needs at least one physical card added.

  1. Go to your Settings => Wallet.
  2. Click on your Physical card => Issue card.
  3. Enter all necessary information => Press Ship card.
  4. Verify that there's modal that allow you to enter magic code.
  5. Enter the magic code.
  6. Verify that you can continue with the flow after that.
  • [x] Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

Same as Tests.

  • [x] Verify that no errors appear in the JS console

PR Author Checklist

  • [x] I linked the correct issue in the ### Fixed Issues section above
  • [x] I wrote clear testing steps that cover the changes made in this PR
    • [x] I added steps for local testing in the Tests section
    • [x] I added steps for the expected offline behavior in the Offline steps section
    • [x] I added steps for Staging and/or Production testing in the QA steps section
    • [x] I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • [x] 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)
    • [x] I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • [x] I included screenshots or videos for tests on all platforms
  • [x] I ran the tests on all platforms & verified they passed on:
    • [x] Android: Native
    • [x] Android: mWeb Chrome
    • [x] iOS: Native
    • [x] iOS: mWeb Safari
    • [x] MacOS: Chrome / Safari
    • [x] MacOS: Desktop
  • [x] 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)
  • [x] I followed proper code patterns (see Reviewing the code)
    • [x] 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)
    • [x] I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • [x] I verified that comments were added to code that is not self explanatory
    • [x] 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.
    • [x] I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • [x] If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • [x] I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • [x] I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • [x] 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.
    • [x] I verified the JSDocs style guidelines (in STYLE.md) were followed
  • [x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • [x] I followed the guidelines as stated in the Review Guidelines
  • [x] 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)
  • [x] I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • [x] 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
  • [x] I verified that if a function's arguments changed that all usages have also been updated correctly
  • [x] If any new file was added I verified that:
    • [x] The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • [x] If a new CSS style is added I verified that:
    • [x] A similar style doesn't already exist
    • [x] The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • [x] If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • [x] 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)
  • [x] 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.
  • [x] If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • [x] If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • [x] I verified that all the inputs inside a form are aligned with each other.
    • [x] I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • [x] If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • [x] If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

https://github.com/user-attachments/assets/7c4c06c9-58c4-4e32-b993-d90e1dc966a8

MacOS: Desktop

https://github.com/user-attachments/assets/45811cfe-f081-4220-9c19-7d673fd470b5

hungvu193 avatar Oct 20 '24 09:10 hungvu193

Note: It looks like BE currently doesn't throw errors with invalid validate code.

hungvu193 avatar Oct 20 '24 10:10 hungvu193

image

I see. This is not related to current changes, however I think it's easy to update it so I can include useOnyx migration in this PR

hungvu193 avatar Oct 23 '24 07:10 hungvu193

@situchan Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

melvin-bot[bot] avatar Oct 24 '24 02:10 melvin-bot[bot]

Onyx migration 's done. I mark this PR is ready so the linked issue won't be overdue.

hungvu193 avatar Oct 24 '24 02:10 hungvu193

@NikkiWines What's the successful response? Can you give me the example? I'm seeing here's the error response, it merges requestPhysicalCardForm key.

Screenshot 2024-11-01 at 11 45 15

hungvu193 avatar Nov 01 '24 04:11 hungvu193

Another thing, The error that's showing between assigned card sections and inside ValidateCodeActionModal are different, do we need to fix it as well?

https://github.com/user-attachments/assets/770123a8-3d71-43d8-8d90-3191b1d4c7c7

hungvu193 avatar Nov 01 '24 07:11 hungvu193

Ah, hmm looks like that response is returned when we need additional action from the admin for the user to get their card provisioned. But it's optimized for Expensify Classic not New Expensify, so we should update that (internally) to be a bit clearer. The message the user receives on Expensify Classic is We're working with your admin to get you your Expensify card ASAP!

For a successful response, you'd see the following:

{
  "cardID": 154,
  "onyxData": [
    {
      "onyxMethod": "merge",
      "key": "cardList",
      "value": {
        "154": {
          "accountID": 28,
          "availableSpend": 1000,
          "bank": "Expensify Card",
          "cardID": 154,
          "cardName": "111111XXXXXX7953",
          "domainName": "test2.com",
          "fraud": "none",
          "fundID": "31",
          "isVirtual": false,
          "lastFourPAN": "",
          "lastScrape": "",
          "lastScrapeResult": 0,
          "nameValuePairs": {
            "expirationDate": "2028-11-30",
            "feedCountry": "US",
            "hasCustomUnapprovedExpenseLimit": true,
            "unapprovedExpenseLimit": 1000
          },
          "scrapeMinDate": "",
          "state": 4
        }
      }
    },
    {
      "key": "private_personalDetails",
      "onyxMethod": "set",
      "value": {
        "addresses": [
          {
            "city": "Beaumont",
            "country": "US",
            "current": true,
            "state": "TX",
            "street": "Test Street",
            "type": "home",
            "zip": "77705"
          }
        ],
        "avatarThumbnail": "https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png",
        "legalFirstName": "User",
        "legalLastName": "TesterTwo",
        "phoneNumber": "+15005550006"
      }
    },
    {
      "key": "cardList",
      "onyxMethod": "merge",
      "value": {
        "154": {
          "accountID": 28,
          "availableSpend": 1000,
          "bank": "Expensify Card",
          "cardID": 154,
          "cardName": "111111XXXXXX7953",
          "domainName": "test2.com",
          "fraud": "none",
          "fundID": "31",
          "isVirtual": false,
          "lastFourPAN": "",
          "lastScrape": "",
          "lastScrapeResult": 0,
          "nameValuePairs": {
            "expirationDate": "2028-11-30",
            "feedCountry": "US",
            "hasCustomUnapprovedExpenseLimit": true,
            "unapprovedExpenseLimit": 1000
          },
          "scrapeMinDate": "",
          "state": 4
        }
      }
    }
  ],
  "jsonCode": 200,
  "requestID": "5HfdsH",
  "previousUpdateID": 18631,
  "lastUpdateID": 18633
}

Also while testing the success flow, I noticed that we don't close or exit the RHP when the user is successfully verified, it just stays open with the validateCode:

NikkiWines avatar Nov 01 '24 19:11 NikkiWines

Also, I get the failure flow when I try to re-submit the validateCode after the original success case, so re-using the same card for testing might be why you're getting that response. I noticed if I try to go through the flow again it's updated to the Activate Physical Card flow, not the Ship Physical Card flow

NikkiWines avatar Nov 01 '24 19:11 NikkiWines

I see. Looks like the isSucessful variable was calculated incorrectly. I'll take a look

hungvu193 avatar Nov 02 '24 06:11 hungvu193

I'm a bit confused about the way we get selected card to issue here: https://github.com/Expensify/App/blob/bef062b4caa7f665159dc107911e708031e648c4/src/pages/settings/Wallet/Card/BaseGetPhysicalCard.tsx#L113-L114

Once the successful data arrives, cardToBeIssued will become undefined because its state is now NOT_ACTIVATED (4).

hungvu193 avatar Nov 04 '24 02:11 hungvu193

Once the successful data arrives, cardToBeIssued will become undefined because its state is now NOT_ACTIVATED (4).

Yeah, I think that's expected, though - the card is no longer not issued; it's been shipped / queued to be shipped to the user, so it's in a non-activated state until they enter the CVV on the back of the card to verify it's been received.

NikkiWines avatar Nov 05 '24 03:11 NikkiWines

Please reassign another C+ as I'll be OOO

situchan avatar Nov 05 '24 07:11 situchan

Once the successful data arrives, cardToBeIssued will become undefined because its state is now NOT_ACTIVATED (4).

Yeah, I think that's expected, though - the card is no longer not issued; it's been shipped / queued to be shipped to the user, so it's in a non-activated state until they enter the CVV on the back of the card to verify it's been received.

Yeah, but it also means cardToBeIssued.isSuccessful will become undefined, so it won't navigate to the next step. I'm finding another way to detect when card is issued sucessfully.

hungvu193 avatar Nov 05 '24 09:11 hungvu193

@NikkiWines Can you check again? I updated the new condition to navigate user to the next route when API was called successfully.

hungvu193 avatar Nov 06 '24 08:11 hungvu193

It works! But I might double-check how we handle the success of validateCode flow for other routes, the end feels a little jarring/abrupt? Maybe a success page or something.

@mountiny do you have any idea? Do we typically show a success message / success page or something for this?

https://github.com/user-attachments/assets/b0081b0a-d2f2-4866-bd06-43f5aa152576

NikkiWines avatar Nov 06 '24 21:11 NikkiWines

@NikkiWines That looks fine to me personally, but I agree we could add a success page. I think it does not have to be in scope of this PR. @koko57 added something similar to when domain is provisioned. We could create issue for the design team to whip something nice up

mountiny avatar Nov 07 '24 13:11 mountiny

Yeah it might be a good thing to add to that re-usable component in general, but agreed it's not a blocker for this PR or necessarily needs to be lumped in to this issue specifically. cc: @Expensify/design thoughts on adding some sort of success notification or page to the newDot in app validation flow? (see here)

NikkiWines avatar Nov 07 '24 20:11 NikkiWines

@hungvu193 is there anything you need to move forward here? Is this ready for review by @dominictb? (thanks for stepping in @dominictb!)

NikkiWines avatar Nov 07 '24 21:11 NikkiWines

Definitely not against a success/confirmation page—we have lots of them sprinkled throughout the app so that shouldn't be a problem. (Also fine with it being a follow-up/not strictly part of this PR).

Also, is it possible to update this screen to match our other magic code screens? The Verify button should be at the bottom like our normal "footer buttons" and any errors should show above it.

CleanShot 2024-11-07 at 15 46 52@2x

cc @Expensify/design

dannymcclain avatar Nov 07 '24 21:11 dannymcclain

@hungvu193 is there anything you need to move forward here? Is this ready for review by @dominictb? (thanks for stepping in @dominictb!)

It's ready for review

hungvu193 avatar Nov 08 '24 00:11 hungvu193

Also, is it possible to update this screen to match our other magic code screens? The Verify button should be at the bottom like our normal "footer buttons" and any errors should show above it.

Ah yeah, we had another PR to fix it, it was merged already, I need to merge this PR with main then the button will be aligned bottom

hungvu193 avatar Nov 08 '24 00:11 hungvu193

Reviewer Checklist

  • [x] I have verified the author checklist is complete (all boxes are checked off).
  • [x] I verified the correct issue is linked in the ### Fixed Issues section above
  • [x] I verified testing steps are clear and they cover the changes made in this PR
    • [x] I verified the steps for local testing are in the Tests section
    • [x] I verified the steps for Staging and/or Production testing are in the QA steps section
    • [x] 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)
    • [x] 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)
  • [x] I checked that screenshots or videos are included for tests on all platforms
  • [x] I included screenshots or videos for tests on all platforms
  • [x] I verified tests pass on all platforms & I tested again on:
    • [x] Android: Native
    • [x] Android: mWeb Chrome
    • [x] iOS: Native
    • [x] iOS: mWeb Safari
    • [x] MacOS: Chrome / Safari
    • [x] MacOS: Desktop
  • [x] 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
  • [x] I verified proper code patterns were followed (see Reviewing the code)
    • [x] 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).
    • [x] I verified that comments were added to code that is not self explanatory
    • [x] 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.
    • [x] I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • [x] I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • [x] I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • [x] 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.
    • [x] I verified the JSDocs style guidelines (in STYLE.md) were followed
  • [x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • [x] I verified that this PR follows the guidelines as stated in the Review Guidelines
  • [x] 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)
  • [x] I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • [x] 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
  • [x] If a new component is created I verified that:
    • [x] A similar component doesn't exist in the codebase
    • [x] All props are defined accurately and each prop has a /** comment above it */
    • [x] The file is named correctly
    • [x] The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • [x] The only data being stored in the state is data necessary for rendering and nothing else
    • [x] 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)
    • [x] 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)
    • [x] All JSX used for rendering exists in the render method
    • [x] 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
  • [x] If any new file was added I verified that:
    • [x] The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • [x] If a new CSS style is added I verified that:
    • [x] A similar style doesn't already exist
    • [x] The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • [x] If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • [x] 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)
  • [x] 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.
  • [x] If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • [x] If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • [x] I verified that all the inputs inside a form are aligned with each other.
    • [x] I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • [x] If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • [x] If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • [x] I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native

https://github.com/user-attachments/assets/bbbbf2cc-c4a0-4422-90aa-737b04aebb50

Android: mWeb Chrome

https://github.com/user-attachments/assets/3f027f75-e142-4e72-b2c6-f587d21cbaee

iOS: Native

https://github.com/user-attachments/assets/c56e2196-849c-421c-a388-ea5e852596ba

iOS: mWeb Safari

https://github.com/user-attachments/assets/26a4912c-2081-4a39-9dfa-4b5650ad0f27

MacOS: Chrome / Safari

https://github.com/user-attachments/assets/b54a5fe4-2ea9-4cfa-92e7-80183e24d6da

MacOS: Desktop

dominictb avatar Nov 12 '24 06:11 dominictb

@hungvu193 Are https://github.com/Expensify/App/pull/51135#issuecomment-2424826532 and https://github.com/Expensify/App/pull/51135#issuecomment-2451425006 expected? Or are we waiting for BE changes?

dominictb avatar Nov 12 '24 07:11 dominictb

@hungvu193 Are #51135 (comment) and #51135 (comment) expected? Or are we waiting for BE changes?

I think they're expected for now. I believe we don't want to block existing user from using this feature at the moment because we haven't released this PR yet. cc @NikkiWines

hungvu193 avatar Nov 12 '24 08:11 hungvu193

I constantly get this error even though I used the correct code.

Screenshot 2024-11-12 at 15 09 45

dominictb avatar Nov 12 '24 08:11 dominictb

BUG: If I abandoned the verify flow (wrong magic code then close the RHP) and refreshed, the card automatically turned to have NOT_ACTIVATED state

But seems like it's this one https://github.com/Expensify/App/pull/51135#issuecomment-2452469217 and a BE bug.

dominictb avatar Nov 12 '24 08:11 dominictb

BUG: If I entered wrong validate code, I would always got Card data missing in detail error like https://github.com/Expensify/App/pull/51135#issuecomment-2451285601 all the time even when I entered the correct code.

I think it is a BE bug as well.

dominictb avatar Nov 12 '24 08:11 dominictb

The above issue ^ together with the rate limit of ResendValidateCode made this PR very difficult to test. I'll try again tonight.

dominictb avatar Nov 12 '24 09:11 dominictb

@dominictb you might be able to test more easily by following the setup steps from this PR? @hungvu193 it might be helpful to incorporate something like this into the QA steps as well

NikkiWines avatar Nov 13 '24 00:11 NikkiWines

Couple of comments

Addressed all the comments

hungvu193 avatar Nov 13 '24 04:11 hungvu193