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

Search - Search history does not show the last 4 card digits #52192

Closed
4 of 8 tasks
lanitochka17 opened this issue Nov 7, 2024 · 14 comments
Closed
4 of 8 tasks

Search - Search history does not show the last 4 card digits #52192

lanitochka17 opened this issue Nov 7, 2024 · 14 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Nov 7, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.59-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause - Internal Team

Issue found when executing PR #51633

Action Performed:

Precondition:

  • User has assigned themselves some virtual cards
  1. Go to staging.new.expensify.com
  2. Open any report
  3. Open search router
  4. Enter cardID
  5. Select a virtual card
  6. Note that it shows last 4 card digits in the search field
  7. Hit Enter
  8. Go back to report
  9. Open search router

Expected Result:

The search history should show the last 4 card digits, as it will cause confusion if user searches for more than one virtual card

Actual Result:

The search history does not show the last 4 card digits

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Bug6657686_1730989900879.20241107_222310.mp4

View all open jobs on GitHub

@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Nov 7, 2024
Copy link

melvin-bot bot commented Nov 7, 2024

Triggered auto assignment to @trjExpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@sarfaraz01578
Copy link

Proposal

Please re-state the problem that we are trying to solve in this issue.

Search - Search history does not show the last 4 card digits

What is the root cause of that problem?

The root cause of this problem is that the application is not formatting or storing the card ID properly when updating the search history. Specifically, the application does not extract the last four digits of the card ID for display purposes, which leads to confusion when the search history is revisited.

What changes do you think we should make in order to solve the problem?

Modify the getFilterCardDisplayTitle function to display only the last 4 digits of the card ID.

function getFilterCardDisplayTitle(filters, cards) {
    const filterValue = filters[CONST.SEARCH.SYNTAX_FILTER_KEYS.CARD_ID];
    
    if (filterValue) {
        const filteredCards = Object.values(cards).filter((card) => filterValue.includes(card.cardID.toString()));
        return filteredCards.map((card) => `**** **** **** ${card.cardID.toString().slice(-4)}`).join(', ');
    }

    return undefined;
}

Update the searchAdvancedFilters state to store the card ID properly, ensuring the last 4 digits are displayed in the search history.

const updatedFilters = {
    ...searchAdvancedFilters,
    [CONST.SEARCH.SYNTAX_FILTER_KEYS.CARD_ID]: cardID, // Store full cardID or last 4 digits
};

What alternative solutions did you explore? (Optional)

Copy link

melvin-bot bot commented Nov 7, 2024

📣 @sarfaraz01578! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@sarfaraz01578
Copy link

Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~018a3960cdaa518f4e

Copy link

melvin-bot bot commented Nov 7, 2024

⚠️ Unable to store contributor details.

@sarfaraz01578
Copy link

Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~018a3960cdaa518f4e

Copy link

melvin-bot bot commented Nov 7, 2024

⚠️ Unable to store contributor details.

@sarfaraz01578
Copy link

Proposal

Please re-state the problem that we are trying to solve in this issue.

Search - Search history does not show the last 4 card digits

What is the root cause of that problem?

The root cause of this problem is that the application is not formatting or storing the card ID properly when updating the search history. Specifically, the application does not extract the last four digits of the card ID for display purposes, which leads to confusion when the search history is revisited.

What changes do you think we should make in order to solve the problem?

Modify the getFilterCardDisplayTitle function to display only the last 4 digits of the card ID.

function getFilterCardDisplayTitle(filters, cards) {
    const filterValue = filters[CONST.SEARCH.SYNTAX_FILTER_KEYS.CARD_ID];
    
    if (filterValue) {
        const filteredCards = Object.values(cards).filter((card) => filterValue.includes(card.cardID.toString()));
        return filteredCards.map((card) => `**** **** **** ${card.cardID.toString().slice(-4)}`).join(', ');
    }

    return undefined;
}

Update the searchAdvancedFilters state to store the card ID properly, ensuring the last 4 digits are displayed in the search history.

const updatedFilters = {
    ...searchAdvancedFilters,
    [CONST.SEARCH.SYNTAX_FILTER_KEYS.CARD_ID]: cardID, // Store full cardID or last 4 digits
};

What alternative solutions did you explore? (Optional)

@truph01
Copy link
Contributor

truph01 commented Nov 7, 2024

Edited by proposal-police: This proposal was edited at 2024-11-07 20:59:19 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

  • The search history does not show the last 4 card digits

What is the root cause of that problem?

  • In the function to get the display card in case the query string is type:expense status:all sortBy:date sortOrder:desc cardID:21472605, we are using:

if (filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.CARD_ID) {
return cardList[filter]?.bank || filter;
}

It only display the bank name. If the bank name data is not available, we revert to the card ID. In case of this bug, it only displays "Expensify Card".

What changes do you think we should make in order to solve the problem?

return cardList[filter]?.bank || filter;

should be updated to:

        return filter || cardList[filter]?.bank;

or

    if (filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.CARD_ID) {
        if (cardList[filter]?.bank && cardList[filter]?.lastFourPAN) {
            return `${cardList[filter]?.bank}-${cardList[filter]?.lastFourPAN}`;
        }
        return filter || cardList[filter]?.bank;
    }

or

    if (filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.CARD_ID) {
        if (cardList[filter]?.bank && filter) {
            return `${cardList[filter]?.bank}-${filter}`;
        }
        return filter || cardList[filter]?.bank;
    }
  • The details about the format to display can be improved in PR.

What alternative solutions did you explore? (Optional)

  • We can also use:
        return getCardDescription(filter) || filter || cardList[filter]?.bank;

@truph01
Copy link
Contributor

truph01 commented Nov 7, 2024

Proposal updated

@melvin-bot melvin-bot bot added the Overdue label Nov 11, 2024
@trjExpensify
Copy link
Contributor

I can reproduce this. @luacmartins just want a hip check from you on whether this is known? I agree it gets confusing to not show the card you've selected to filter on.

@melvin-bot melvin-bot bot removed the Overdue label Nov 12, 2024
@luacmartins
Copy link
Contributor

This is known and @Kicu is working on updates to the search results bar to display the correct names and work with autocomplete as well

@luacmartins
Copy link
Contributor

We can either close or put this on hold for now

@trjExpensify
Copy link
Contributor

Dope, let's close it then!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2
Projects
None yet
Development

No branches or pull requests

5 participants