Skip to content

[Due for payment 2026-01-06] [$250] Expensify Card feed defaults to other workspace after enabling Expensify Card in other workspace #65593

Closed

Description

@jponikarchuk

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.1.77-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp https://expensify.testrail.io/index.php?/tests/view/6436914
Email or phone of affected tester (no customers): applausetester+070706kh@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.5 / Chrome
App Component: Workspace Settings

Action Performed:

Precondition:

  • Workspace A has enabled Expensify Card feature with at least one assigned card.
  1. Go to staging.expensify.com
  2. Create a new workspace B.
  3. Go to workspace settings > More features.
  4. Enable Expensify Card.
  5. Go to Expensify Card.
  6. Click Issue new card.
  7. Select the bank account.
  8. Click Got it.
  9. Go back to Workspace A settings (that has at least one assigned Expensify card).
  10. Go to Expensify Card.
  11. Expensify Card feed from Workspace B is auto-selected, when user is on Workspace A.
  12. Click on the Expensify Card feed dropdown.
  13. The selected card feed is not highlighted.
  14. Click on the current card feed and reopen card feed list.
  15. Now the selected card feed is highlighted.

Expected Result:

In Step 11, when user opens Expensify Card on Workspace A, card feed from Workspace A will be selected.
In Step 13, the selected card feed will be highlighted.

Actual Result:

In Step 11, when user opens Expensify Card on Workspace A, card feed from Workspace B is opened instead.
In Step 13, the selected card feed is not highlighted.
In Step 15, after user reselects the current card feed and reopens the card feed list, the selected card feed is highlighted.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021942356016062233779
  • Upwork Job ID: 1942356016062233779
  • Last Price Increase: 2025-07-14
  • Automatic offers:
    • thelullabyy | Contributor | 108213577
Issue OwnerCurrent Issue Owner: @
Issue OwnerCurrent Issue Owner: @twisterdotcom

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 7, 2025
  2. melvin-bot commented on Jul 7, 2025

    @melvin-bot

    Triggered auto assignment to @twisterdotcom (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.

  3. daledah commented on Jul 7, 2025

    @daledah
    Contributor

    Proposal

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

    In Step 11, when user opens Expensify Card on Workspace A, card feed from Workspace B is opened instead.
    In Step 13, the selected card feed is not highlighted.
    In Step 15, after user reselects the current card feed and reopens the card feed list, the selected card feed is highlighted.

    What is the root cause of that problem?

    We are based on LAST_SELECTED_EXPENSIFY_CARD_FEED Onyx to set the default fund id here

    if (lastSelectedExpensifyCardFeed) {
    return lastSelectedExpensifyCardFeed;
    }

    But we don't update the LAST_SELECTED_EXPENSIFY_CARD_FEED when a user visits an expensify card page in another workspace

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

    1. We can rely on domainName to get policyID similar to here
      const getPolicyIDFromDomainName = (domainName: string): string | undefined => {
          const policyID = domainName.match(CONST.REGEX.EXPENSIFY_POLICY_DOMAIN_NAME)?.[1];
          if (policyID) {
              return policyID;
          }
          return undefined;
      };
    

    App/src/libs/PolicyUtils.ts

    Lines 1409 to 1411 in d9daefe

    const getDescriptionForPolicyDomainCard = (domainName: string): string => {
    // A domain name containing a policyID indicates that this is a workspace feed
    const policyID = domainName.match(CONST.REGEX.EXPENSIFY_POLICY_DOMAIN_NAME)?.[1];

    1. Then we will update LAST_SELECTED_EXPENSIFY_CARD_FEED when the user accesses a different policy in WorkspaceExpensifyCardPage component
        const allExpensifyCardFeeds = useExpensifyCardFeeds(policyID);
        let currentFundID = defaultFundID;
        Object.entries(allExpensifyCardFeeds ?? {}).forEach(([key, value]) => {
            if (getPolicyIDFromDomainName(value?.domainName ?? '') !== policyID) {
                return;
            }
            currentFundID = getFundIdFromSettingsKey(key);
        });
    
        useEffect(() => {
            if (currentFundID === defaultFundID) {
                return;
            }
            updateSelectedExpensifyCardFeed(currentFundID, policyID);
        }, [currentFundID, policyID, defaultFundID]);
    

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    None

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 7, 2025
  5. changed the title [-]Expensify Card feed defaults to other workspace after enabling Expensify Card in other workspace[/-] [+][$250] Expensify Card feed defaults to other workspace after enabling Expensify Card in other workspace[/+] on Jul 7, 2025
  6. melvin-bot commented on Jul 7, 2025

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 7, 2025
  8. melvin-bot commented on Jul 7, 2025

    @melvin-bot

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

  9. thelullabyy commented on Jul 8, 2025

    @thelullabyy
    Contributor

    Proposal

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

    Problem 1: When user opens Expensify Card on Workspace A, card feed from Workspace B is opened instead.
    Problem 2: the selected card feed is not highlighted.

    What is the root cause of that problem?

    Firstly, let's see this hook

    function useDefaultFundID(policyID: string | undefined) {
    const workspaceAccountID = useWorkspaceAccountID(policyID);
    const [lastSelectedExpensifyCardFeed] = useOnyx(`${ONYXKEYS.COLLECTION.LAST_SELECTED_EXPENSIFY_CARD_FEED}${policyID}`, {canBeMissing: true});
    const [domainFundID] = useOnyx(ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS, {
    selector: (cardSettings) => {
    const matchingKey = Object.entries(cardSettings ?? {}).find(
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    ([key, settings]) => settings?.preferredPolicy && settings.preferredPolicy === policyID && !key.includes(workspaceAccountID.toString()),
    );
    return getFundIdFromSettingsKey(matchingKey?.[0] ?? '');
    },
    canBeMissing: true,
    });
    if (lastSelectedExpensifyCardFeed) {
    return lastSelectedExpensifyCardFeed;
    }
    if (domainFundID) {
    return domainFundID;
    }
    if (workspaceAccountID) {
    return workspaceAccountID;
    }
    return CONST.DEFAULT_NUMBER_ID;
    }

    In the first time going to Expensify Card on Workspace A, both lastSelectedExpensifyCardFeed and domainFundID are unavailable.

    Note: lastSelectedExpensifyCardFeed only be updated if we select the option from Expensify Card Selector

    So useDefaultFundID return workspaceAccountID

    When creating the card feed from Workspace B, by some way (relying on workspace setup), this feed is set to domainFundID. And in the next time, we go to Expensify Card on Workspace A, useDefaultFundID return domainFundID that belongs workspace B

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

    In the Expensify Card page, we need to LAST_SELECTED_EXPENSIFY_CARD_FEED to reflect the correct fund ID it is displaying

    const fetchExpensifyCards = useCallback(() => {
    openPolicyExpensifyCardsPage(policyID, defaultFundID);
    }, [policyID, defaultFundID]);
    const {isOffline} = useNetwork({onReconnect: fetchExpensifyCards});

        const fetchExpensifyCards = useCallback(() => {
            updateSelectedExpensifyCardFeed(defaultFundID, policyID);
            openPolicyExpensifyCardsPage(policyID, defaultFundID);
        }, [policyID, defaultFundID]);
    

    As a result of the above solution, problem 2 is also fixed because we will don't change feed anymore

    Problem 2: the selected card feed is not highlighted.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    NA

    What alternative solutions did you explore? (Optional)

    NA

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  10. self-assigned this
    on Jul 8, 2025
  11. dangrous commented on Jul 8, 2025

    @dangrous
    Contributor

    Happy to help with internal review here when it's ready!

  12. 78 remaining items

  13. melvin-bot commented on Dec 30, 2025

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  14. melvin-bot commented on Dec 30, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.88-7 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-01-06. 🎊

    For reference, here are some details about the assignees on this issue:

  15. melvin-bot commented on Dec 30, 2025

    @melvin-bot

    @Pujan92 @twisterdotcom The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  16. Pujan92 commented on Jan 6, 2026

    @Pujan92
    Contributor

    I think we don't need a checklist here as the preferred policy can't be updated in ND and this will be considered as an edge case.

  17. melvin-bot commented on Jan 8, 2026

    @melvin-bot

    @twisterdotcom Whoops! This issue is 2 days overdue. Let's get this updated quick!

  18. twisterdotcom commented on Jan 9, 2026

    @twisterdotcom
    Contributor

    Payment Summary:

  19. twisterdotcom commented on Jan 10, 2026

    @twisterdotcom
    Contributor

    @Pujan92 has submitted payment for this report on ND here.

    SO: https://stackoverflowteams.com/c/expensify/questions/7582

    Zapier Logs Run ID: 00040eee-89c7-a39e-f73f-852500851ef4
  20. trjExpensify commented on Jan 19, 2026

    @trjExpensify
    Contributor

    Confirming payment summary here is correct.

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions