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

Update the Assigned Cards Section of the Wallet Page #38998

Merged

Conversation

SzymczakJ
Copy link
Contributor

@SzymczakJ SzymczakJ commented Mar 26, 2024

Details

This PR changes the way cards are shown on the WalletPage. Cards from the same domain are grouped under the same card row when card is not issued by an admin. When card was issued by the admin then this card will have it's own separate row. After clicking on each of these rows user will be taken to a ExpensifyCardPage, which shows all the cards grouped under the domain or a single card depending which row was clicked.
We determine if the card was issued by an admin by checking if card.nameValuePairs.issuedBy field exists.

Fixed Issues

$ #38468
PROPOSAL:

Tests

  • To test this, without having any cards linked, put this useEffect in the WalletPage:
useEffect(() => {
        if (cardList[234523452345]) {
            return;
        }
        // eslint-disable-next-line rulesdir/prefer-actions-set-data
        Onyx.merge(`cardList`, {
            1234123412341234: {
                key: '1234123412341234',
                cardID: 1234123412341234,
                state: 3,
                bank: 'Expensify Card',
                availableSpend: 1000000,
                domainName: 'cathycroissants.com',
                nameValuePairs: {
                    cardTitle: 'Amazon Card(title)',
                    limitType: 'smart',
                    isVirtual: false,
                },
                isVirtual: false,
                fraud: 'none',
                lastFourPAN: '1234',
            },
            2345234523452345: {
                key: '2345234523452345',
                cardID: 2345234523452345,
                state: 3,
                bank: 'Expensify Card',
                availableSpend: 1000000,
                domainName: 'cathycroissants.com',
                nameValuePairs: {
                    cardTitle: 'Amazon Card(title)',
                    limitType: 'smart',
                    isVirtual: false,
                },
                isVirtual: false,
                fraud: 'none',
                lastFourPAN: '2345',
            },
            3456345634563456: {
                key: '3456345634563456',
                cardID: 3456345634563456,
                state: 3,
                bank: 'Expensify Card',
                availableSpend: 10000,
                domainName: 'cathycroissants.com',
                nameValuePairs: {
                    limitType: 'smart',
                    isVirtual: true,
                },
                isVirtual: true,
                fraud: 'none',
                lastFourPAN: '3456',
            },
            5678567856785678: {
                key: '5678567856785678',
                cardID: 5678567856785678,
                state: 3,
                bank: 'Expensify Card',
                availableSpend: 500000,
                domainName: 'cathydumplings.com',
                nameValuePairs: {
                    cardTitle: 'Adobe Subscription',
                    issuedBy: 100,
                    limitType: 'smart',
                    isVirtual: true,
                },
                isVirtual: true,
                fraud: 'none',
                lastFourPAN: '2311',
            },
            4567456745674567: {
                key: '4567456745674567',
                cardID: 4567456745674567,
                state: 3,
                bank: 'Expensify Card',
                availableSpend: 20000,
                domainName: 'cathycinamons.com',
                nameValuePairs: {
                    cardTitle: 'Netflix subscription',
                    issuedBy: 100,
                    limitType: 'fixed',
                    isVirtual: true,
                },
                isVirtual: true,
                fraud: 'none',
                lastFourPAN: '2311',
            },

            123412341234: {
                key: '123412341234',
                cardID: 123412341234,
                state: 3,
                bank: 'Amazon Card',
                availableSpend: 30000,
                nameValuePairs: {
                    issuedBy: 100,
                    limitType: 'fixed',
                    isVirtual: false,
                },
                domainName: 'kubson.com',
                isVirtual: false,
                fraud: 'none',
                lastFourPAN: '1234',
            },
        });
    }, [cardList]);

  • Try clicking on different card rows, check if the ExpensifyCardPage shows correctly.

Tests Extended

Precondition:
Provision the FE using below data:

  useEffect(() => {
       if (cardList[234523452345]) {
           return;
       }
       // eslint-disable-next-line rulesdir/prefer-actions-set-data
       Onyx.merge(`cardList`, {
           1234123412341234: {
               key: '1234123412341234',
               cardID: 1234123412341234,
               state: 4,
               bank: 'Expensify Card',
               availableSpend: 5000000,
               domainName: 'cathycroissants.com',
               nameValuePairs: {
                   cardTitle: 'Amazon Card(title)',
                   limitType: 'smart',
                   isVirtual: false,
               },
               isVirtual: false,
               fraud: 'none',
               lastFourPAN: '1234',
           },
           2345234523452345: {
               key: '2345234523452345',
               cardID: 2345234523452345,
               state: 3,
               bank: 'Expensify Card',
               availableSpend: 3000000,
               domainName: 'cathycroissants.com',
               nameValuePairs: {
                   cardTitle: 'Amazon Card(title)',
                   limitType: 'smart',
                   isVirtual: false,
                   issuedBy: 100,
               },
               isVirtual: false,
               fraud: 'none',
               lastFourPAN: '2345',
           },
           3456345634563456: {
               key: '3456345634563456',
               cardID: 3456345634563456,
               state: 3,
               bank: 'Expensify Card',
               availableSpend: 5000000,
               domainName: 'cathycroissants.com',
               nameValuePairs: {
                   limitType: 'smart',
                   isVirtual: true,                    
               },
               isVirtual: true,
               fraud: 'none',
               lastFourPAN: '3456',
           },
           5678567856785678: {
               key: '5678567856785678',
               cardID: 5678567856785678,
               state: 3,
               bank: 'Expensify Card',
               availableSpend: 500000,
               domainName: 'cathydumplings.com',
               nameValuePairs: {
                   cardTitle: 'Adobe Subscription',
                   issuedBy: 100,
                   limitType: 'monthly',
                   isVirtual: true,
               },
               isVirtual: true,
               fraud: 'none',
               lastFourPAN: '2311',
           },
           4567456745674567: {
               key: '4567456745674567',
               cardID: 4567456745674567,
               state: 3,
               bank: 'Expensify Card',
               availableSpend: 20000,
               domainName: 'cathycinamons.com',
               nameValuePairs: {
                   cardTitle: 'Netflix subscription',
                   issuedBy: 100,
                   limitType: 'fixed',
                   isVirtual: true,
               },
               isVirtual: true,
               fraud: 'none',
               lastFourPAN: '2311',
           },

           123412341234: {
               key: '123412341234',
               cardID: 123412341234,
               state: 3,
               bank: 'Amazon Card',
               availableSpend: 30000,
               nameValuePairs: {
                   issuedBy: 100,
                   limitType: 'fixed',
                   isVirtual: false,
               },
               domainName: 'kubson.com',
               isVirtual: false,
               fraud: 'none',
               lastFourPAN: '1234',
           },
       });
   }, [cardList]); 

Test 1: Cards from the same domain are grouped under the same card row when card is not issued by an admin

  1. Verify presence of assigned card with title Expensify Card and domain cathycroissants.com and click on the same.
  2. The cards with id 1234123412341234 and 3456345634563456 are grouped together. Verify that the virtual card with cardID 3456345634563456 is displayed.

Test 2: When card was issued by the admin then this card will have it's own separate row

  1. Verify presence of assigned card with title Amazon Card(title) and domain cathycroissants.com and click on the same.
  2. Verify card with id 2345234523452345 is displayed.

Test 3: Show card limit type Smart and the limit specific description

  1. Click on assigned card with title Expensify Card and domain cathycroissants.com
  2. Verify that the limit type Smart limit and description with text You can spend up to $50,000.00 on this card, and the limit will reset as your submitted expenses are approved. is displayed.

Test 4: Show card limit type Monthly and the limit specific description

  1. Click on assigned card with title Adobe Subscription and domain cathydumplings.com
  2. Verify that the limit type Monthly limit and description with text You can spend up to $5,000.00 on this card per month. The limit will reset on the 1st day of each calendar month. is displayed.

Test 5: Show card limit type Fixed and the limit specific description

  1. Click on assigned card with title Netflix subscription and domain cathycinamons.com
  2. Verify that the limit type Fixed limit and description with text You can spend up to $200.00 on this card, and then it will deactivate. is displayed.

Test 6: Show the activate button if ANY of the cards in this group are in the NOT_ACTIVATED state

  1. Click on assigned card with title Expensify Card and domain cathycroissants.com
  2. Verify that the Activate physical card button is displayed as card with id 1234123412341234 is in NOT_ACTIVATED state.

Test 7: Show Report virtual card fraud page

  1. Click on assigned card with title Expensify Card and domain cathycroissants.com
  2. Click on Report virtual card fraud to launch the report fraud page
  3. Click back to navigate back to assigned card page.

Test 8: Show Report physical card loss / damage page

  1. Click on assigned card with title Amazon Card(title) and domain cathycroissants.com
  2. Click on Report physical card loss / damage to launch the loss/damage page
  3. Click back to navigate back to assigned card page.

Test 9: Make the card non interactive if the card is non Expensify Card

  1. Verify that the assigned card with title Amazon Card and domain kubson.com is non-interactive. Also, right icon should be hidden

Offline tests

QA Steps

  • Verify that no errors appear in the JS console

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 the expected offline behavior in the Offline steps 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 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).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • 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 the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • 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 is localized by adding it to src/languages/* files and using the translation method
      • 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:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • 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
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • 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
  • 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(theme.componentBG))
  • 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.
  • 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.
  • 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.
  • 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:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • 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.
  • 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.mov
Android: mWeb Chrome
android.web.mov
iOS: Native
ios.mov
iOS: mWeb Safari
iosweb.mov
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
deskltop.mov

Copy link
Contributor

@Kicu Kicu left a comment

Choose a reason for hiding this comment

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

Looks mostly good to me. I found several small codestyle tweaks that I think you could apply to make this cleaner, so if you have time then please do them or respond to me if something doesnt make sense.

Otherwise Im approving this b/c I see no big breaking bugs 👍
I have not run this, only reviewed the code.

[SCREENS.SETTINGS.REPORT_CARD_LOST_OR_DAMAGED]: {
/** domain passed via route /settings/wallet/card/:domain/:card */
domain: string;
/** cardId passed via route /settings/wallet/card/:domain/:card */
Copy link
Contributor

Choose a reason for hiding this comment

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

While I understand this style of comment is already used in this file, I still find it kinda redundant.

Do you really think its needed? and if yes then could we write it in some more human-friendly way?
For example there is a comment in line 141
/** Currently selected country */
^ that reads much better

so something like // the domain of the current card etc

const domainCards = useMemo(() => cardList && CardUtils.getDomainCards(cardList)[domain], [cardList, domain]);
const virtualCard = useMemo(() => domainCards?.find((card) => card.isVirtual), [domainCards]);
const physicalCard = useMemo(() => domainCards?.find((card) => !card.isVirtual), [domainCards]);
const isCardDomain = !cardList?.[cardId].isAdminIssuedVirtualCard;
Copy link
Contributor

Choose a reason for hiding this comment

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

I find name isCardDomain hard to understand. What actually does this variable mean:

  • is something a card domain?
  • is the card of domain type?
  • does the card domain exist?

this is a nitpick but if you have a better idea for a name, then I'd update it

const [cardDetailsError, setCardDetailsError] = useState('');

const cardsToShow = useMemo(
() => (isCardDomain ? CardUtils.getDomainCards(cardList)[domain].filter((card) => !card.isAdminIssuedVirtualCard) : [cardList?.[cardId]]),
Copy link
Contributor

Choose a reason for hiding this comment

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

to me this 1 liner reads very hard.

() => {
if (isCardDomain) {
   return CardUtils.getDomainCards(cardList)[domain].filter((card) => !card.isAdminIssuedVirtualCard);
}
return [cardList?.[cardId]]

maybe this is better?

setIsCardDetailsLoading((prevState: Record<number, boolean>) => {
const newLoadingStates = {...prevState};
newLoadingStates[revealedCardId] = true;
return newLoadingStates;
Copy link
Contributor

Choose a reason for hiding this comment

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

would this work?

return {
   ...prevState,
   [revealedCardId]: true
}

I find this more readable than creating a temporary const

setCardsDetailsErrors((prevState) => {
const newCardsDetailsErrors = {...prevState};
newCardsDetailsErrors[revealedCardId] = error;
return newCardsDetailsErrors;
Copy link
Contributor

Choose a reason for hiding this comment

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

in all 3 cases I believe it should be possible to use the pattern:

return {
   ...prevState,
   [fieldKey]: newValue
}

return {limitName: translate('cardPage.fixedLimit.name'), limitTitle: translate('cardPage.fixedLimit.title', formattedAvailableSpendAmount)};
default:
return {limitName: '', limitTitle: ''};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

it feels kinda dirty to define this type of function within the component body. Please move this out of the component, keep in this file but above the component.

There are 2 ways to handle that you don't have the translate function outside of component scope.
Either:

  • make your function accept a 2nd argument, which will be the translate fn
  • instead of returning objects with results of running translate, return objects with strings (translation keys) and then inside the component call translate(...) on them

Choose whichever you think is better in this case.

shouldShowRightIcon
onPress={() => Navigation.navigate(ROUTES.SETTINGS_WALLET_REPORT_CARD_LOST_OR_DAMAGED.getRoute(domain, cardId))}
/>
</>
Copy link
Contributor

Choose a reason for hiding this comment

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

in such cases I personally prefer to do the longer version of arrow: () => { ... } so that I can do an early return, instead of &&.

I find its easier to reason what gets returned if the code looks something like this:

{
  [...]
  if (!SOME_CONSTS) {
    return null
  }

  return <>JSX....</>
}

@grgia grgia self-requested a review April 2, 2024 16:39
@SzymczakJ SzymczakJ force-pushed the @szymczak/update-cards-section branch from 222fa0b to a10788e Compare April 8, 2024 12:06
@grgia
Copy link
Contributor

grgia commented Apr 8, 2024

Running a test build :)

This comment has been minimized.

@grgia
Copy link
Contributor

grgia commented Apr 8, 2024

Hmm @SzymczakJ

For this data

           {
                "1": {
                    "availableSpend": 1000000,
                    "bank": "Expensify Card",
                    "cardID": 1,
                    "domainName": "expensify.com",
                    "fraud": "none",
                    "isVirtual": false,
                    "lastFourPAN": "9967",
                    "nameValuePairs": {
                        "expensifyCard_integrationPolicyId": "ASDFGHJKL",
                        "expirationDate": "2026-08-31",
                        "hasCustomUnapprovedExpenseLimit": false,
                        "netsuite_export_payable_account": "2440",
                        "previousState": 7,
                        "unapprovedExpenseLimit": 1000000
                    },
                    "state": 3
                },
                "2": {
                    "availableSpend": 1000000,
                    "bank": "Expensify Card",
                    "cardID": 2,
                    "domainName": "expensify.com",
                    "fraud": "none",
                    "isVirtual": true,
                    "lastFourPAN": "4736",
                    "nameValuePairs": {
                        "expensifyCard_digitalWalletToken": [
                            "cdea0dae-804b-4fe0-b681-9cd04a39ebbe",
                            "b408697b-5844-4b6e-9ab7-adc362f9d2e8"
                        ],
                        "expensifyCard_integrationPolicyId": "ASDFGHJKL",
                        "expensifyCard_panReferenceID": "ASDFGHJKL",
                        "expensifyCard_tokenReferenceIdList": [
                            "DNITHE382222871289503945",
                            "DNITHE462306361609704972"
                        ],
                        "expirationDate": "2026-08-31",
                        "hasCustomUnapprovedExpenseLimit": false,
                        "isVirtual": true,
                        "netsuite_export_payable_account": "2440",
                        "previousState": 7,
                        "unapprovedExpenseLimit": 1000000
                    },
                    "state": 3
                },
                "3": {
                    "availableSpend": 1000000,
                    "bank": "Expensify Card",
                    "cardID": 3,
                    "domainName": "expensify.com",
                    "fraud": "none",
                    "isVirtual": false,
                    "lastFourPAN": "",
                    "nameValuePairs": {
                        "feedCountry": "US",
                        "hasCustomUnapprovedExpenseLimit": false,
                        "unapprovedExpenseLimit": 1000000
                    },
                    "state": 2
                }
           }

Here's the page:

image

This is totally correct based on the mocks, but in interacting with it I think I'd like to hear design input.

For the case that a user already has a physical card and is reprovisioned a second one while the first is still active, I think we could show some kind of copy or indication to the user that they've been provisioned a new card. For example, Green brick road from the wallet to the card page and add a second physical card row with copy explaining that they've been provisioned a new card or something

Any thoughts? @Expensify/design

@shawnborton
Copy link
Contributor

I could totally see that. Is there any action to be taken on the new physical card once it's provisioned though? Just thinking in terms of how these patterns technically work, the green brick road typically means there is something you need to do or an action you need to take. We typically don't use it just to tell you that new data is available. That being said, we don't have any kind of "unread" pattern for Settings either.

@dannymcclain
Copy link
Contributor

I could totally see that. Is there any action to be taken on the new physical card once it's provisioned though?

Yeah curious about this too because like Shawn said, we don't usually GBR things unless there's something for you to do.

@grgia
Copy link
Contributor

grgia commented Apr 10, 2024

I could totally see that. Is there any action to be taken on the new physical card once it's provisioned though? Just thinking in terms of how these patterns technically work, the green brick road typically means there is something you need to do or an action you need to take. We typically don't use it just to tell you that new data is available. That being said, we don't have any kind of "unread" pattern for Settings either.

@shawnborton @dannymcclain

I missed this at first as well, but the user needs to open the card page and click on this button to go through the get new card flow to order their new card. It's not really clear, but this indicates that there's a third new card

image

@shawnborton
Copy link
Contributor

That makes sense. But I thought you were asking if we should put a green brick road dot on the new card row once they go through that flow you just referenced? I think we are leaning towards no, because once the card is created, there is no further action to take.

Copy link
Contributor

@grgia grgia left a comment

Choose a reason for hiding this comment

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

Quick first pass review, let's make sure all instances of cardID have capitalized ID

src/libs/Navigation/types.ts Outdated Show resolved Hide resolved

useEffect(
() => () => {
CardSettings.clearCardListErrors(cardID);
CardSettings.clearCardListErrors(physicalCard?.cardID ?? 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm do we want to default to 0 here? It looks like it would merge 0 into the cardList

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe not though? would 0: {} work?

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 could just do if and an early return. Dunno why I didn't think of that. Defaulting to 0 would probably cause bugs 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah let's do an early return instead

Comment on lines 111 to 112
CardSettings.activatePhysicalExpensifyCard(lastFourDigits, physicalCard?.cardID ?? 0);
}, [lastFourDigits, physicalCard?.cardID]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should default to a negative ID

Copy link
Contributor Author

@SzymczakJ SzymczakJ Apr 12, 2024

Choose a reason for hiding this comment

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

We could but isn't 0 also a wrong card ID and would cause CardSettings.activatePhysicalExpensifyCard to fail(which is what we want when physical card doesn't have cardID). Do we have some special negative number for such cases?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah 0 is an incorrect card ID. I think we've historically used -1 but I need to double check. But let me know if you'll try returning early instead

@SzymczakJ SzymczakJ requested a review from grgia April 12, 2024 18:37
Copy link
Contributor

@grgia grgia left a comment

Choose a reason for hiding this comment

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

Minor comments

@@ -104,30 +104,30 @@ function ExpensifyCardPage({
const [isCardDetailsLoading, setIsCardDetailsLoading] = useState<Record<number, boolean>>({});
const [cardsDetailsErrors, setCardsDetailsErrors] = useState<Record<number, string>>({});

const handleRevealDetails = (revealedCardId: number) => {
const handleRevealDetails = (revealedcardID: number) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

revealedCardID

Copy link
Contributor

Choose a reason for hiding this comment

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

(camel case)


useEffect(
() => () => {
CardSettings.clearCardListErrors(cardID);
CardSettings.clearCardListErrors(physicalCard?.cardID ?? 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah let's do an early return instead

Comment on lines 111 to 112
CardSettings.activatePhysicalExpensifyCard(lastFourDigits, physicalCard?.cardID ?? 0);
}, [lastFourDigits, physicalCard?.cardID]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah 0 is an incorrect card ID. I think we've historically used -1 but I need to double check. But let me know if you'll try returning early instead

@SzymczakJ SzymczakJ requested a review from grgia April 16, 2024 10:35
@SzymczakJ
Copy link
Contributor Author

@grgia just fixed your comments

@grgia
Copy link
Contributor

grgia commented Apr 19, 2024

@SzymczakJ could we move this out of drafts today so C+ can take a passover as well?

@SzymczakJ
Copy link
Contributor Author

@rojiphil fixed your comments and uploaded PR author checklist 😸

@grgia grgia requested a review from rojiphil April 25, 2024 11:36
Copy link
Contributor

@rojiphil rojiphil left a comment

Choose a reason for hiding this comment

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

The code looks good. I have left a comment for a small change. We are much closer to the finishing line. And I should be able to complete my checklist tomorrow if all things go well.

@@ -109,24 +109,25 @@ function BaseGetPhysicalCard({
const styles = useThemeStyles();
const isRouteSet = useRef(false);

const domainCards = CardUtils.getDomainCards(cardList)[domain] || [];
const cardToBeIssued = domainCards.find((card) => !card?.nameValuePairs?.isVirtual && card?.state === CONST.EXPENSIFY_CARD.STATE.STATE_NOT_ISSUED);
const cardID = cardToBeIssued?.cardID ?? 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be good to use cardID as string (like cardToBeIssued?.cardID?.toString() ?? ‘’) instead of calling toString many times. We need cardID as a number only in requestPhysicalExpensifyCard where we can use cardToBeIssued?.cardID ?? 0. This will make the code look neater too. What do you think?

@grgia
Copy link
Contributor

grgia commented Apr 26, 2024

triggered one more build

Copy link
Contributor

@grgia
Copy link
Contributor

grgia commented Apr 26, 2024

Testing on my card test account:
image

@SzymczakJ for the combo card, which ID is used in the route? It seems weird to use a cardID if there's two cards here
See:
image

Can we use the domain just for this case?

@grgia
Copy link
Contributor

grgia commented Apr 26, 2024

These pages LGTM :)
image
image

Copy link
Contributor

@grgia grgia left a comment

Choose a reason for hiding this comment

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

Chatted about the design, and I think we're actually good to go! LGTM and Tests well. Ping me for merge @rojiphil

@rojiphil
Copy link
Contributor

@SzymczakJ Can you please update the Tests section in Author Checklist with the following text? This will help QA to test the implementation here. I found this useful in generating test videos. Thanks.

Precondition:
Provision the FE using below data:

  useEffect(() => {
       if (cardList[234523452345]) {
           return;
       }
       // eslint-disable-next-line rulesdir/prefer-actions-set-data
       Onyx.merge(`cardList`, {
           1234123412341234: {
               key: '1234123412341234',
               cardID: 1234123412341234,
               state: 4,
               bank: 'Expensify Card',
               availableSpend: 5000000,
               domainName: 'cathycroissants.com',
               nameValuePairs: {
                   cardTitle: 'Amazon Card(title)',
                   limitType: 'smart',
                   isVirtual: false,
               },
               isVirtual: false,
               fraud: 'none',
               lastFourPAN: '1234',
           },
           2345234523452345: {
               key: '2345234523452345',
               cardID: 2345234523452345,
               state: 3,
               bank: 'Expensify Card',
               availableSpend: 3000000,
               domainName: 'cathycroissants.com',
               nameValuePairs: {
                   cardTitle: 'Amazon Card(title)',
                   limitType: 'smart',
                   isVirtual: false,
                   issuedBy: 100,
               },
               isVirtual: false,
               fraud: 'none',
               lastFourPAN: '2345',
           },
           3456345634563456: {
               key: '3456345634563456',
               cardID: 3456345634563456,
               state: 3,
               bank: 'Expensify Card',
               availableSpend: 5000000,
               domainName: 'cathycroissants.com',
               nameValuePairs: {
                   limitType: 'smart',
                   isVirtual: true,                    
               },
               isVirtual: true,
               fraud: 'none',
               lastFourPAN: '3456',
           },
           5678567856785678: {
               key: '5678567856785678',
               cardID: 5678567856785678,
               state: 3,
               bank: 'Expensify Card',
               availableSpend: 500000,
               domainName: 'cathydumplings.com',
               nameValuePairs: {
                   cardTitle: 'Adobe Subscription',
                   issuedBy: 100,
                   limitType: 'monthly',
                   isVirtual: true,
               },
               isVirtual: true,
               fraud: 'none',
               lastFourPAN: '2311',
           },
           4567456745674567: {
               key: '4567456745674567',
               cardID: 4567456745674567,
               state: 3,
               bank: 'Expensify Card',
               availableSpend: 20000,
               domainName: 'cathycinamons.com',
               nameValuePairs: {
                   cardTitle: 'Netflix subscription',
                   issuedBy: 100,
                   limitType: 'fixed',
                   isVirtual: true,
               },
               isVirtual: true,
               fraud: 'none',
               lastFourPAN: '2311',
           },

           123412341234: {
               key: '123412341234',
               cardID: 123412341234,
               state: 3,
               bank: 'Amazon Card',
               availableSpend: 30000,
               nameValuePairs: {
                   issuedBy: 100,
                   limitType: 'fixed',
                   isVirtual: false,
               },
               domainName: 'kubson.com',
               isVirtual: false,
               fraud: 'none',
               lastFourPAN: '1234',
           },
       });
   }, [cardList]); 

Test 1: Cards from the same domain are grouped under the same card row when card is not issued by an admin

  1. Verify presence of assigned card with title Expensify Card and domain cathycroissants.com and click on the same.
  2. The cards with id 1234123412341234 and 3456345634563456 are grouped together. Verify that the virtual card with cardID 3456345634563456 is displayed.

Test 2: When card was issued by the admin then this card will have it's own separate row

  1. Verify presence of assigned card with title Amazon Card(title) and domain cathycroissants.com and click on the same.
  2. Verify card with id 2345234523452345 is displayed.

Test 3: Show card limit type Smart and the limit specific description

  1. Click on assigned card with title Expensify Card and domain cathycroissants.com
  2. Verify that the limit type Smart limit and description with text You can spend up to $50,000.00 on this card, and the limit will reset as your submitted expenses are approved. is displayed.

Test 4: Show card limit type Monthly and the limit specific description

  1. Click on assigned card with title Adobe Subscription and domain cathydumplings.com
  2. Verify that the limit type Monthly limit and description with text You can spend up to $5,000.00 on this card per month. The limit will reset on the 1st day of each calendar month. is displayed.

Test 5: Show card limit type Fixed and the limit specific description

  1. Click on assigned card with title Netflix subscription and domain cathycinamons.com
  2. Verify that the limit type Fixed limit and description with text You can spend up to $200.00 on this card, and then it will deactivate. is displayed.

Test 6: Show the activate button if ANY of the cards in this group are in the NOT_ACTIVATED state

  1. Click on assigned card with title Expensify Card and domain cathycroissants.com
  2. Verify that the Activate physical card button is displayed as card with id 1234123412341234 is in NOT_ACTIVATED state.

Test 7: Show Report virtual card fraud page

  1. Click on assigned card with title Expensify Card and domain cathycroissants.com
  2. Click on Report virtual card fraud to launch the report fraud page
  3. Click back to navigate back to assigned card page.

Test 8: Show Report physical card loss / damage page

  1. Click on assigned card with title Amazon Card(title) and domain cathycroissants.com
  2. Click on Report physical card loss / damage to launch the loss/damage page
  3. Click back to navigate back to assigned card page.

Test 9: Make the card non interactive if the card is non Expensify Card

  1. Verify that the assigned card with title Amazon Card and domain kubson.com is non-interactive. Also, right icon should be hidden

Copy link
Contributor

@rojiphil rojiphil left a comment

Choose a reason for hiding this comment

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

@grgia LGTM and tests well too.

@melvin-bot melvin-bot bot requested a review from grgia April 26, 2024 17:21
@grgia grgia merged commit 6a37cd8 into Expensify:main Apr 29, 2024
16 of 17 checks passed
@grgia
Copy link
Contributor

grgia commented Apr 29, 2024

Great work @SzymczakJ

Thank you for the reviews @rojiphil

@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

🚀 Cherry-picked to staging by https://github.com/francoisl in version: 1.4.67-7 🚀

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

@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/grgia in version: 1.4.68-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Cherry-picked to staging by https://github.com/francoisl in version: 1.4.67-7 🚀

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

@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes.

@OSBotify
Copy link
Contributor

OSBotify commented May 1, 2024

🚀 Deployed to production by https://github.com/francoisl in version: 1.4.68-3 🚀

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

if (!inactiveCard?.cardID) {
return;
}
CardSettings.clearCardListErrors(inactiveCard?.cardID);
Copy link
Contributor

Choose a reason for hiding this comment

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

Error is not cleared when page is reloaded, #51396

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants