Skip to content

[HOLD] [$175] Company card nicknames don’t show in the Spend page Card filter #102683

Open

Description

@m-natarajan

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.4.99-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from BrowserStack:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @greg-schroeder
Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

  1. As a workspace admin, go to Workspaces > [Workspace] > Company cards
  2. Click a card and set a Card name (nickname)
  3. Go to Spend and open the Card filter

Expected Result:

Each card row shows “last 4 · card nickname,” and you can search the filter by nickname. This was added in #52554.

Actual Result:

Rows show only the last 4 and the cardholder’s name. The nickname doesn’t appear and can’t be searched.

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Recording.3614.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @brunovjk

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 30, 2026
  2. MelvinBot commented on Sep 30, 2026

    @MelvinBot
    Contributor

    Proposal

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

    In the Spend page Card filter, company card rows show only the last 4 digits and the cardholder's name. The admin-set card nickname doesn't appear, and you can't search the list by nickname.

    What is the root cause of that problem?

    The filter reads the nickname from a different place than where the app saves it.

    • The filter row reads the nickname from card.nameValuePairs.cardTitle (CardFeedUtils.ts:83). It checks the custom-name NVP only for personal cards (CardFeedUtils.ts:87-90).
    • The workspace Card name page saves company card nicknames to the shared NVP settings.companyCardCustomNames and to nvp_expensify_ccCustomNames (CompanyCards.ts:771-782). Every workspace screen reads the nickname back through getCompanyCardCustomName (CardUtils.ts:1220-1229).
    • CardSelector never subscribes to the shared NVP (CardSelector.tsx:47). As a result, cardName is empty for company cards, and the subtitle shows only the last 4.
    • Search matches on item.cardName (CardSelector.tsx:83-87). Since cardName is empty, a nickname search finds nothing.

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

    1. In CardSelector, subscribe to ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER. Use a selector that merges each entry's settings.companyCardCustomNames into one cardID → name map. Pass that map to buildCardsData, then on to createCardFilterItem.
    2. In createCardFilterItem, for company cards (not personal, not Expensify Card), set cardName to getCompanyCardCustomName(cardID, sharedNames, customCardNames). Fall back to nameValuePairs.cardTitle when no custom name exists. Leave the Expensify Card and personal card logic unchanged.
    3. Add a unit test in tests/unit/Search/buildCardFilterDataTest.ts: a company card with a shared custom name should return that name as cardName.

    Search works after this change with no other edits, because it already matches on cardName.

    What alternative solutions did you explore? (Optional)

    Look up the name only in the shared NVP entry keyed by card.fundID. That avoids merging all entries, but it assumes fundID always equals the domainOrWorkspaceAccountID used in the NVP key. I haven't confirmed that assumption.

    Investigation details

    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/102683) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 30, 2026
  4. melvin-bot commented on Sep 30, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @ChavdaSachin (External)

  5. changed the title [-]Company card nicknames don’t show in the Spend page Card filter[/-] [+][$175] Company card nicknames don’t show in the Spend page Card filter[/+] on Sep 30, 2026
  6. melvin-bot commented on Sep 30, 2026

    @melvin-bot
  7. camesenin commented on Sep 30, 2026

    @camesenin
  8. bonnhatnguyen commented on Sep 30, 2026

    @bonnhatnguyen

    Proposal

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

    In the Spend page Search filters, when opening the Card filter (CardSelector), company cards display only the cardholder's display name and last 4 digits. The admin-configured custom nickname does not display in the row subtitle, and searching for the card by its nickname returns no results.


    What is the root cause of that problem?

    There are two reasons why company card nicknames fail to display and search:

    1. createCardFilterItem gates custom card name resolution behind isPersonal:
      In src/libs/CardFeedUtils.ts (lines 83–90):

      let cardName = card?.nameValuePairs?.cardTitle;
      const text = personalDetails?.displayName ?? cardName;
      const plaidUrl = getPlaidInstitutionIconUrl(card?.bank);
      const isCSVImportCard = card?.bank === CONST.PERSONAL_CARDS.BANK_NAME.CSV;
      const isPersonal = isPersonalCard(card);
      if (isPersonal && !isCSVImportCard) {
          cardName = customCardNames?.[card?.cardID] ?? card?.cardName;
      }

      Even though CardSelector subscribes to ONYXKEYS.NVP_EXPENSIFY_COMPANY_CARDS_CUSTOM_NAMES and passes customCardNames to buildCardsData, createCardFilterItem checks if (isPersonal && !isCSVImportCard).
      For company cards, isPersonal is false. Thus, createCardFilterItem never inspects customCardNames for company cards and leaves cardName as card?.nameValuePairs?.cardTitle.

    2. Company card nicknames are also stored in shared workspace NVPs:
      When workspace admins rename company cards, names are stored in ONYXKEYS.NVP_EXPENSIFY_COMPANY_CARDS_CUSTOM_NAMES and shared domain member NVPs under ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER. Other screens (such as WorkspaceCompanyCardsTable) resolve company card names using CardUtils.getCompanyCardCustomName(cardID, sharedCardCustomNames, customCardNames).
      Because CardSelector does not subscribe to ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER, and createCardFilterItem does not use getCompanyCardCustomName, cardName remains empty/undefined for company cards.

    3. Search filtering fails on nicknames:
      In CardSelector.tsx (lines 83–87):

      const searchFunction = (item: CardFilterItem) =>
          !!item.text?.toLocaleLowerCase().includes(debouncedSearchTerm.toLocaleLowerCase()) ||
          !!item.lastFourPAN?.toLocaleLowerCase().includes(debouncedSearchTerm.toLocaleLowerCase()) ||
          !!item.cardName?.toLocaleLowerCase().includes(debouncedSearchTerm.toLocaleLowerCase()) || ...

      Since item.cardName is empty for company cards, filtering by nickname fails to match.


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

    1. Add a selector for shared company card custom names in src/selectors/Card.ts:
    /** Merges shared company card custom names across all workspace domain members */
    const allSharedCompanyCardCustomNamesSelector = (sharedNvp: OnyxCollection<CardFeeds>): Record<string, string> => {
        const combined: Record<string, string> = {};
        for (const member of Object.values(sharedNvp ?? {})) {
            if (!member?.settings?.companyCardCustomNames) {
                continue;
            }
            Object.assign(combined, member.settings.companyCardCustomNames);
        }
        return combined;
    };

    Export allSharedCompanyCardCustomNamesSelector.

    1. In src/components/Search/FilterComponents/CardSelector.tsx:
    • Subscribe to ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER using allSharedCompanyCardCustomNamesSelector:
    + const [sharedCardCustomNames] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER, {selector: allSharedCompanyCardCustomNamesSelector});
    • Pass sharedCardCustomNames to buildCardsData:
      const individualCardsSectionData = buildCardsData(
          workspaceCardFeeds ?? {},
          userCardList ?? {},
          personalDetails ?? {},
          value,
          illustrations,
          companyCardFeedIcons,
          false,
          customCardNames,
    +     sharedCardCustomNames,
      );
    1. In src/libs/CardFeedUtils.ts:
    • Update createCardFilterItem and buildCardsData to accept sharedCardCustomNames?: Record<string, string>.
    • In createCardFilterItem, use getCompanyCardCustomName for non-personal, non-Expensify company cards:
    --- a/src/libs/CardFeedUtils.ts
    +++ b/src/libs/CardFeedUtils.ts
    @@ -8,7 +8,7 @@ import {
         formatMaskedCardName,
    +    getCompanyCardCustomName,
         getDefaultCardName,
         isCard,
    @@ -77,6 +77,7 @@ function createCardFilterItem(
         companyCardIcons: CompanyCardFeedIcons,
         customCardNames?: Record<string, string>,
    +    sharedCardCustomNames?: Record<string, string>,
     ): CardFilterItem {
         const personalDetails = personalDetailsList[card?.accountID ?? CONST.DEFAULT_NUMBER_ID];
         const isSelected = selectedCards.includes(card.cardID.toString());
         const icon = getCardFeedIcon(card?.bank, illustrations, companyCardIcons);
         let cardName = card?.nameValuePairs?.cardTitle;
         const text = personalDetails?.displayName ?? cardName;
         const plaidUrl = getPlaidInstitutionIconUrl(card?.bank);
         const isCSVImportCard = card?.bank === CONST.PERSONAL_CARDS.BANK_NAME.CSV;
         const isPersonal = isPersonalCard(card);
         if (isPersonal && !isCSVImportCard) {
             cardName = customCardNames?.[card?.cardID] ?? card?.cardName;
    +    } else if (!isExpensifyCard(card)) {
    +        cardName = getCompanyCardCustomName(card?.cardID, sharedCardCustomNames, customCardNames) ?? card?.nameValuePairs?.cardTitle;
         }
    1. Add Unit Test in tests/unit/Search/buildCardFilterDataTest.ts:
    • Verify that a company card with a custom nickname in customCardNames or sharedCardCustomNames produces item.cardName equal to the custom nickname.
    • Verify that filtering with searchFunction matches the nickname.

    What alternative solutions did you explore? (Optional)

    Only fallback to customCardNames?.[card?.cardID] without reading SHARED_NVP_PRIVATE_DOMAIN_MEMBER. However, company cards configured by other workspace admins store nicknames in the shared NVP, so subscribing via allSharedCompanyCardCustomNamesSelector ensures parity with WorkspaceCompanyCardsTable.

  9. camesenin commented on Oct 1, 2026

    @camesenin
  10. camesenin commented on Oct 1, 2026

    @camesenin
  11. camesenin commented on Oct 1, 2026

    @camesenin
  12. melvin-bot commented on Oct 1, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  13. melvin-bot commented on Oct 5, 2026

    @melvin-bot

    @ChavdaSachin Eep! 4 days overdue now. Issues have feelings too...

  14. 17 remaining items

  15. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Nov 3, 2026
  16. melvin-bot commented on Nov 3, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @brunovjk (External)

  17. mallenexpensify commented on Nov 3, 2026

    @mallenexpensify
    Contributor

    @brunovjk plz take over as C+

  18. melvin-bot commented on Nov 9, 2026

    @melvin-bot

    @brunovjk Eep! 4 days overdue now. Issues have feelings too...

  19. brunovjk commented on Nov 10, 2026

    @brunovjk
  20. brunovjk commented on Nov 11, 2026

    @brunovjk
    Contributor

    Hey @tgolen, any update on the card nickname refactor? Thanks!

  21. tgolen commented on Nov 11, 2026

    @tgolen
    Contributor
  22. brunovjk commented on Nov 16, 2026

    @brunovjk
    Contributor

    Expensify/Expensify#672937 to know exactly where

    It seems I don't have access.

  23. expensify-chore-bot commented on Nov 19, 2026

    @expensify-chore-bot

    @brunovjk Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

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

Metadata

Metadata

Assignees

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorOverdue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions