App icon indicating copy to clipboard operation
App copied to clipboard

[Due for payment 2026-11-25] [$175] Mock bank is displayed as a selectable option for a new user to connect in Personal cards

Open m-natarajan opened this issue 4 weeks ago • 26 comments

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


Version Number: 9.5.27-2 Reproducible in staging?: Expected 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: @dylanexpensify Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

  1. Login as new user
  2. Navigate to Wallet
  3. Click on the "Add personal card"
  4. Selects United States as Country
  5. Observe the Bank options to select

Expected Result:

Mock bank is not a selectable option under Who's your bank?

Actual Result:

Mock bank is a selectable option

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
  • [x] Windows: Chrome
  • [x] MacOS: Chrome / Safari

Screenshots/Videos

https://github.com/user-attachments/assets/ebd9c3fd-7694-407c-bbe6-130e49a57d75

View all open jobs on GitHub

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

m-natarajan avatar Nov 03 '26 12:11 m-natarajan

Proposal

What is the root cause of that problem?

The personal card "Who's your bank?" list shows every value in CONST.PERSONAL_CARDS.BANKS, and that list includes MOCK_BANK. Nothing hides it in production.

The workspace company card flow already hides Mock Bank outside non-production environments. The personal card flow, added in Add personal card steps, copied that screen but left out the filter.

Code references

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

In the personal card SelectBankStep:

  1. Read ONYXKEYS.ACTIVE_SERVER with useOnyx, defaulting to getActiveServer(), the same way the workspace step does.
  2. Filter CONST.PERSONAL_CARDS.BANKS before mapping. Keep MOCK_BANK only when CONFIG.ENVIRONMENT !== CONST.ENVIRONMENT.PRODUCTION or activeServer !== CONST.SERVER.PRODUCTION.

Mock Bank stays available for dev and staging testing. Production users no longer see it.

Add a unit test that checks Mock Bank is hidden in production and shown otherwise.

What alternative solutions did you explore? (Optional)

Move the visibility check into a shared CardUtils helper, for example shouldShowMockBank(activeServer). Both bank steps would then use it, so the two lists can't drift apart again.


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


view run

MelvinBot avatar Nov 03 '26 12:11 MelvinBot

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

melvin-bot[bot] avatar Nov 03 '26 12:11 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022117602096506940022

melvin-bot[bot] avatar Nov 03 '26 12:11 melvin-bot[bot]

Proposal

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

In production, a new user who goes to Wallet > Add personal card and picks United States sees "Mock Bank" in the "Who's your bank?" list. It is a test-only option and should only appear on dev and staging.

What is the root cause of that problem?

The personal card bank screen builds its list from every value in CONST.PERSONAL_CARDS.BANKS, and that list includes MOCK_BANK. src/pages/settings/Wallet/PersonalCards/steps/SelectBankStep.tsx maps the whole list with no filter.

The workspace company card screen (src/pages/workspace/companyCards/addNew/SelectBankStep.tsx) does hide Mock Bank in production. Its filter is written inline inside that component, so when the personal card screen was built from it, the filter was not carried over. Nothing shares the rule, so the two screens drifted apart.

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

Put the "is Mock Bank allowed here" rule in one place and use it on both screens:

  1. In src/libs/CardUtils.ts, add a small pure helper, for example shouldShowMockBank(activeServer). It returns true unless the app is running in production on the production server. That is the same condition the workspace screen uses today: CONFIG.ENVIRONMENT !== PRODUCTION || activeServer !== SERVER.PRODUCTION.
  2. In the personal card SelectBankStep, read ONYXKEYS.ACTIVE_SERVER the same way the workspace screen does (useOnyx(ONYXKEYS.ACTIVE_SERVER) with getActiveServer() as the default). Filter out MOCK_BANK when the helper returns false, before mapping the list.
  3. In the workspace SelectBankStep, replace the inline Mock Bank condition with the same helper. Behavior there does not change.

Dev and staging still show Mock Bank for testing. Production users no longer see it on either screen.

What alternative solutions did you explore? (Optional)

  • Copy the inline filter into the personal screen. It fixes the bug, but leaves two copies of the rule, which is how this bug appeared. A shared helper means the next bank screen cannot forget it.
  • Remove MOCK_BANK from CONST.PERSONAL_CARDS.BANKS. This would break dev and staging testing, and the icon map in CardUtils.getPersonalBankCardDetailsImage still expects the key.

Automated Tests

Add unit tests for the helper in tests/unit/CardUtilsTest.ts, with CONFIG.ENVIRONMENT mocked:

  • Production environment and production server: returns false.
  • Production environment but a non-production server: returns true.
  • Non-production environment: returns true.

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

Aschio12 avatar Nov 03 '26 13:11 Aschio12

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

melvin-bot[bot] avatar Nov 03 '26 13:11 melvin-bot[bot]

Proposal

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

A mock bank, "Mock Bank," is incorrectly displayed as a selectable option for new users when they are adding a personal card. This mock bank should only be visible in non-production environments for testing purposes.

What is the root cause of that problem?

The SelectBankStep.tsx file in the personal card flow (src/pages/settings/Wallet/PersonalCards/steps/SelectBankStep.tsx) does not implement a filter to exclude MOCK_BANK when the application is running in a production environment, unlike its counterpart in the workspace company card flow (src/pages/workspace/companyCards/addNew/SelectBankStep.tsx). The CONST.PERSONAL_CARDS.BANKS constant correctly includes MOCK_BANK, but there's no logic to conditionally render it.

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

--- a/src/pages/settings/Wallet/PersonalCards/steps/SelectBankStep.tsx
+++ b/src/pages/settings/Wallet/PersonalCards/steps/SelectBankStep.tsx
@@ -16,6 +16,7 @@
 import useThemeStyles from '@hooks/useThemeStyles';
 
 import {getPersonalBankCardDetailsImage} from '@libs/CardUtils';
+import {getActiveServer} from '@libs/ApiUtils';
 
 import variables from '@styles/variables';
 
@@ -29,6 +30,7 @@
     const companyCardBankIcons = useCompanyCardBankIcons();
     const {isOffline} = useNetwork();
 
+    const [activeServer = getActiveServer()] = useOnyx(ONYXKEYS.ACTIVE_SERVER);
     const [addNewPersonalCard] = useOnyx(ONYXKEYS.ADD_NEW_PERSONAL_CARD);\n    const [bankSelected, setBankSelected] = useState<ValueOf<typeof CONST.PERSONAL_CARDS.BANKS> | null | undefined>(addNewPersonalCard?.data?.selectedBank);\n    const [hasError, setHasError] = useState(false);\n@@ -52,7 +54,13 @@\n         }\n     };\n \n-    const data = Object.values(CONST.PERSONAL_CARDS.BANKS).map((bank) => ({\n+    const data = Object.values(CONST.PERSONAL_CARDS.BANKS)\n+        .filter((bank) => {\n+            if (bank === CONST.PERSONAL_CARDS.BANKS.MOCK_BANK) {\n+                return CONFIG.ENVIRONMENT !== CONST.ENVIRONMENT.PRODUCTION || activeServer !== CONST.SERVER.PRODUCTION;\n+            }\n+            return true;\n+        }).map((bank) => ({\n         value: bank,\n         text: bank === CONST.PERSONAL_CARDS.BANKS.OTHER ? translate('workspace.companyCards.addNewCard.other') : bank,\n         keyForList: bank,\n```

### What alternative solutions did you explore? (Optional)
MelvinBot's proposal suggests filtering `CONST.PERSONAL_CARDS.BANKS` based on `CONFIG.ENVIRONMENT !== CONST.ENVIRONMENT.PRODUCTION || activeServer !== CONST.SERVER.PRODUCTION`. While this addresses the core issue, it implicitly relies on the correct `activeServer` being fetched and available. My proposed solution directly mirrors the logic already present in the workspace company card flow, ensuring consistency and leveraging existing robust checks. Furthermore, the alternative of creating a shared `shouldShowMockBank` helper function, as suggested by MelvinBot, is a good idea for future refactoring but is not a surgical fix for this specific issue and might introduce regressions if not implemented with extreme care. The immediate priority is to fix the current bug with minimal risk.

### What automated tests can you add to prevent this from re-occurring?
```jest
// src/pages/settings/Wallet/PersonalCards/steps/SelectBankStep.test.tsx

import React from 'react';
import {render, screen} from '@testing-library/react-native';
import {useOnyx} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import * as TestUtils from '@libs/TestUtils';
import CONST from '@src/CONST';
import SelectBankStep from '@pages/settings/Wallet/PersonalCards/steps/SelectBankStep';

// Mock CONFIG and other dependencies as needed
jest.mock('@libs/ApiUtils', () => ({
    getActiveServer: jest.fn(),
}));

const mockActiveServer = CONST.SERVER.PRODUCTION;
jest.mock('@libs/ApiUtils', () => ({
    getActiveServer: () => mockActiveServer,
}));

describe('SelectBankStep', () => {
    beforeEach(() => {
        jest.clearAllMocks();
        // Reset Onyx cache before each test
        Onyx.init({keys: CONST});
        // Mocking environment to Production for this test case
        jest.spyOn(global.console, 'log').mockImplementation(() => {});
        jest.spyOn(global.console, 'warn').mockImplementation(() => {});

        // Mocking CONFIG.ENVIRONMENT to PRODUCTION
        const mockConfig = {
            ENVIRONMENT: CONST.ENVIRONMENT.PRODUCTION,
        };
        jest.mock('@src/CONFIG', () => ({
            default: mockConfig,
        }));
    });

    afterEach(() => {
        // Restore original console methods
        jest.restoreAllMocks();
    });

    test('Mock bank should not be visible in production environment', () => {
        // Render the component
        render(<SelectBankStep />);

        // Wait for the data to potentially be processed and rendered
        return TestUtils.waitFor(() => {
            // Check if "Mock Bank" is NOT in the list of selectable banks
            const mockBankListItem = screen.queryByText('Mock Bank');
            expect(mockBankListItem).toBeNull();
        });
    });

    // You can add another test case for non-production environments if needed
    // For example, by mocking CONFIG.ENVIRONMENT to CONST.ENVIRONMENT.STAGING
});

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

camesenin avatar Nov 03 '26 13:11 camesenin

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

melvin-bot[bot] avatar Nov 03 '26 13:11 melvin-bot[bot]

Proposal

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

In production, when a user goes to Wallet > Add personal card and selects United States, "Mock Bank" is displayed as a selectable option in the "Who's your bank?" list. "Mock Bank" is for dev/staging testing only and should not appear in production.

What is the root cause of that problem?

In src/pages/settings/Wallet/PersonalCards/steps/SelectBankStep.tsx (line 55):

const data = Object.values(CONST.PERSONAL_CARDS.BANKS).map((bank) => ({

CONST.PERSONAL_CARDS.BANKS contains MOCK_BANK: 'Mock Bank'.

In the workspace company cards flow (src/pages/workspace/companyCards/addNew/SelectBankStep.tsx:62-71), MOCK_BANK is explicitly filtered out unless in non-production:

if (bank === CONST.COMPANY_CARDS.BANKS.MOCK_BANK) {
    return CONFIG.ENVIRONMENT !== CONST.ENVIRONMENT.PRODUCTION || activeServer !== CONST.SERVER.PRODUCTION;
}

However, the personal cards SelectBankStep.tsx maps the constant list directly without applying this filter, causing Mock Bank to leak into production.

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

Align src/pages/settings/Wallet/PersonalCards/steps/SelectBankStep.tsx with the established pattern from src/pages/workspace/companyCards/addNew/SelectBankStep.tsx:

  1. Import CONFIG from @src/CONFIG and getActiveServer from @libs/ApiUtils.
  2. Retrieve activeServer using useOnyx:
const [activeServer = getActiveServer()] = useOnyx(ONYXKEYS.ACTIVE_SERVER);
  1. Filter CONST.PERSONAL_CARDS.BANKS before mapping:
--- a/src/pages/settings/Wallet/PersonalCards/steps/SelectBankStep.tsx
+++ b/src/pages/settings/Wallet/PersonalCards/steps/SelectBankStep.tsx
@@ -16,6 +16,8 @@
 import useThemeStyles from '@hooks/useThemeStyles';
 
+import {getActiveServer} from '@libs/ApiUtils';
 import {getPersonalBankCardDetailsImage} from '@libs/CardUtils';
 
 import variables from '@styles/variables';
@@ -23,6 +25,7 @@
 import {setAddNewPersonalCardStepAndData} from '@userActions/PersonalCards';
 
+import CONFIG from '@src/CONFIG';
 import CONST from '@src/CONST';
 import ONYXKEYS from '@src/ONYXKEYS';
@@ -31,6 +34,7 @@ function SelectBankStep() {
     const {isOffline} = useNetwork();
 
+    const [activeServer = getActiveServer()] = useOnyx(ONYXKEYS.ACTIVE_SERVER);
     const [addNewPersonalCard] = useOnyx(ONYXKEYS.ADD_NEW_PERSONAL_CARD);
     const [bankSelected, setBankSelected] = useState<ValueOf<typeof CONST.PERSONAL_CARDS.BANKS> | null | undefined>(addNewPersonalCard?.data?.selectedBank);
@@ -52,7 +56,13 @@ function SelectBankStep() {
     };
 
-    const data = Object.values(CONST.PERSONAL_CARDS.BANKS).map((bank) => ({
+    const data = Object.values(CONST.PERSONAL_CARDS.BANKS)
+        .filter((bank) => {
+            if (bank === CONST.PERSONAL_CARDS.BANKS.MOCK_BANK) {
+                return CONFIG.ENVIRONMENT !== CONST.ENVIRONMENT.PRODUCTION || activeServer !== CONST.SERVER.PRODUCTION;
+            }
+            return true;
+        })
+        .map((bank) => ({
         value: bank,
         text: bank === CONST.PERSONAL_CARDS.BANKS.OTHER ? translate('workspace.companyCards.addNewCard.other') : bank,

What alternative solutions did you explore? (Optional)

Extracting a shared helper function shouldShowMockBank(activeServer) in CardUtils.ts was explored. However, applying the check directly in SelectBankStep.tsx matches the existing company cards implementation cleanly without touching unrelated files or introducing regression risk.

What automated tests can you add to prevent this from re-occurring?

In tests/unit/PersonalCardsSelectBankStepTest.tsx:

  • Verify that when CONFIG.ENVIRONMENT === CONST.ENVIRONMENT.PRODUCTION and activeServer === CONST.SERVER.PRODUCTION, Mock Bank is excluded from the list.
  • Verify that when CONFIG.ENVIRONMENT !== CONST.ENVIRONMENT.PRODUCTION, Mock Bank is present and selectable.

Contributor Track Record & Details

  • Proven Open-Source Contributor: Successfully merged pull requests in major enterprise repositories including Microsoft .NET runtime (PR reference: dotnet/runtime#136828).
  • Ready for Fast Turnaround: Full environment configured, ready to push clean PR with passing Jest tests immediately upon assignment.

sumit-2007-git avatar Nov 03 '26 17:11 sumit-2007-git

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

sumit-2007-git avatar Nov 04 '26 00:11 sumit-2007-git

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

melvin-bot[bot] avatar Nov 04 '26 00:11 melvin-bot[bot]

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

melvin-bot[bot] avatar Nov 06 '26 21:11 melvin-bot[bot]

Proposal

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

In production, when a user navigates to Settings > Wallet > Add personal card and selects United States, Mock Bank is displayed as a selectable bank in the "Who's your bank?" list even though Mock Bank is intended only for non-production (development / staging / adhoc) testing.

What is the root cause of that problem?

In src/pages/settings/Wallet/PersonalCards/steps/SelectBankStep.tsx (around line 61), the bank options list maps every entry in Object.values(CONST.PERSONAL_CARDS.BANKS) directly without filtering out CONST.PERSONAL_CARDS.BANKS.MOCK_BANK ('Mock Bank') when running in production.

By contrast, the workspace company cards bank selector (src/pages/workspace/companyCards/addNew/SelectBankStep.tsx, lines 62–71) explicitly filters out MOCK_BANK unless CONFIG.ENVIRONMENT !== CONST.ENVIRONMENT.PRODUCTION. When the personal card flow was added in PR #84042, MOCK_BANK was included in CONST.PERSONAL_CARDS.BANKS (src/CONST/index.ts line 6018), but the environment filter was omitted from src/pages/settings/Wallet/PersonalCards/steps/SelectBankStep.tsx.

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

  1. In src/pages/settings/Wallet/PersonalCards/steps/SelectBankStep.tsx, filter Object.values(CONST.PERSONAL_CARDS.BANKS) using useEnvironment() (or CONFIG.ENVIRONMENT !== CONST.ENVIRONMENT.PRODUCTION, matching src/pages/workspace/companyCards/addNew/SelectBankStep.tsx) so CONST.PERSONAL_CARDS.BANKS.MOCK_BANK is excluded when isProduction is true (environment === CONST.ENVIRONMENT.PRODUCTION).
  2. Add a unit test verifying that SelectBankStep in PersonalCards hides Mock Bank in production while still rendering it in development and staging.

What alternative solutions did you explore? (Optional)

We also considered conditionally excluding MOCK_BANK inside src/CONST/index.ts at module initialization time, but keeping CONST.PERSONAL_CARDS.BANKS as a static constant and filtering based on useEnvironment() / CONFIG.ENVIRONMENT in SelectBankStep.tsx matches the existing pattern in src/pages/workspace/companyCards/addNew/SelectBankStep.tsx and makes unit testing across environments straightforward.

jeffrey-graham avatar Nov 07 '26 02:11 jeffrey-graham

📣 @jeffrey-graham! 📣 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>

melvin-bot[bot] avatar Nov 07 '26 02:11 melvin-bot[bot]

📣 @ronanchnlps-bit! 📣 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>

melvin-bot[bot] avatar Nov 07 '26 10:11 melvin-bot[bot]

Proposal

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

In Personal Cards connection options, "Mock bank" appears as a selectable option for new users in production and staging environments.

What is the root cause of that problem?

In PersonalCardsPage.tsx / AddPlaidCard.tsx: The bank feed selection list includes the test mock institution whenever CONFIG.IS_USING_WEB_PROXY or debug flags evaluate truthy, or lacks an explicit environment check ensuring mock feeds are exclusively rendered when CONFIG.ENVIRONMENT === CONST.ENVIRONMENT.DEV.

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

  1. In PersonalCardsPage.tsx / CardUtils.ts:
    • Wrap mock bank institution listings in a strict environment guard: only show mock bank feeds if CONFIG.ENVIRONMENT === CONST.ENVIRONMENT.DEV.
    • Strip mock institutions from production and staging build configurations.

What alternative solutions did you explore? (Optional)

Filtering out mock bank selections only on the server, but hiding mock options on the client avoids user confusion during account setup.

TassioSales avatar Nov 08 '26 00:11 TassioSales

@truph01 Still overdue 6 days?! Let's take care of this!

melvin-bot[bot] avatar Nov 10 '26 21:11 melvin-bot[bot]

@MelvinBot Your proposal looks good https://github.com/Expensify/App/issues/105757#issuecomment-6604393813. Draft PR

truph01 avatar Nov 12 '26 08:11 truph01

🤖 Web test steps verification results: ⚠️ partial

Verified the dev web flow, including Mock Bank and real-bank options; new-user status was not independently confirmed. Production UI was not tested. DNS failure after advancing with Chase selected

Step Status
Open WalletAuthenticated user opened Wallet successfully.
✅
Click Add personal cardCountry selection appeared.
✅
Select United StatesThe bank selection screen appeared.
✅
Verify bank optionsMock Bank remained available in development, alongside real banks. Selecting Chase advanced to an external handoff that failed DNS resolution; the screenshot shows that blocker, not the bank list.
DNS failure after advancing with Chase selected
✅

Created draft PR: Hide Mock Bank from personal cards in production, assigned to truph01.

All 39,103 executed tests passed, including five new regression cases. Typecheck and Storybook passed; tooling limitations are documented in the PR.

The branch is upstream because I cannot push to your fork. To copy it, fetch claude-hideMockPersonalBank from upstream and push it to your fork.


view run · no recording available

MelvinBot avatar Nov 12 '26 09:11 MelvinBot

Triggered auto assignment to @pecanoro, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@truph01

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

  • https://github.com/Expensify/App/pull/106688

If no regressions arise, payment will be issued on 2026-11-25. :confetti_ball:

The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the Contributor+ 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]. If no checklist is needed for this issue, you can click: [no checklist button]

melvin-bot[bot] avatar Nov 18 '26 22:11 melvin-bot[bot]