Skip to content

Expensify Card feed defaults to other workspace after enabling Expensify Card in other workspace - #67374

Merged
dangrous merged 3 commits into
Expensify:mainfrom
thelullabyy:fix/65593-epsf-cardfeed-default-to-other-workspace
Dec 26, 2025
Merged

dangrous merged 3 commits into
Expensify:mainfrom
thelullabyy:fix/65593-epsf-cardfeed-default-to-other-workspace

Conversation

@thelullabyy

@thelullabyy thelullabyy commented Jul 30, 2025 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Fixed Issues

$#65593
PROPOSAL:#65593 (comment)

Tests

Precondition:

  • Workspace A has enabled Expensify Card feature with at least one assigned card.
  1. Open app
  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. Verify card feed from Workspace A still be selected
  12. Click on the Expensify Card feed dropdown.
  13. Verify selected card feed is highlighted
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

Precondition:

  • Workspace A has enabled Expensify Card feature with at least one assigned card.
  1. Open app
  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. Verify card feed from Workspace A still be selected
  12. Click on the Expensify Card feed dropdown.
  13. Verify selected card feed is highlighted
  • 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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • 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 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 used JaimeGPT to get English > Spanish translation. I then posted it 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.ts 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 new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • 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.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • 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: mWeb Chrome
android_web.mov
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
chorme.mov
MacOS: Desktop
desktop.mov

@thelullabyy
thelullabyy marked this pull request as ready for review July 30, 2025 04:27
@thelullabyy
thelullabyy requested a review from a team as a code owner July 30, 2025 04:27
@melvin-bot
melvin-bot Bot requested review from allroundexperts and removed request for a team July 30, 2025 04:27
@melvin-bot

melvin-bot Bot commented Jul 30, 2025

Copy link
Copy Markdown

@allroundexperts Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@thelullabyy

Copy link
Copy Markdown
Contributor Author

@allroundexperts I'm not able to mock data new workspace card feed on native and ios safari. Could you please help me check it on?

@dangrous

dangrous commented Aug 4, 2025

Copy link
Copy Markdown
Contributor

@allroundexperts are you able to help out with the testing here?

@allroundexperts

Copy link
Copy Markdown
Contributor

Hey @dangrous!
I'll try to test this tomorrow. If you don't hear from me till then, feel free to re-assign.

@dangrous

dangrous commented Aug 5, 2025

Copy link
Copy Markdown
Contributor

Okay thanks! and @thelullabyy were you able to review this proposal and see if there was anything useful we wanted to implement?

@allroundexperts

Copy link
Copy Markdown
Contributor

Hi @thelullabyy!
I can not seem to activate the Expensify card feature on the second workspace. Were you able to do that or did you just tested via Onyx.merge? If so, please share the content of this call with me.

@thelullabyy

Copy link
Copy Markdown
Contributor Author

@allroundexperts Yup, i tested via Onyx.merge. You can use this:

Onyx.merge("private_expensifyCardSettings_2", {
    currentBalance: 0,
    earnedCashback: 0,
    isLoading: false,
    isMonthlySettlementAllowed: false,
    limit: 0,
    marqetaBusinessToken: 2,
    ownerEmail: "epsfttest123@gmail.com",
    paymentBankAccountID: 6121177,
    remainingLimit: 0,
    preferredPolicy: "<paste your policyID>"
});

@allroundexperts

Copy link
Copy Markdown
Contributor

@thelullabyy I'm getting the following even after executing your code.

Screen.Recording.2025-08-06.at.1.00.09.PM.mov

@Pujan92

Pujan92 commented Aug 6, 2025 •

Copy link
Copy Markdown
Contributor

@thelullabyy I am seeing an issue of the lastSelectedExpensifyCardFeed_ udpated on refresh within your PR which should persist the last selection.

Screen.Recording.2025-08-06.at.22.38.53.mov

I believe logically we should not update the selected card feed onyx every time when we visit WorkspaceExpensifyCard Page, instead it would be better if we correct the conditions.

@thelullabyy

thelullabyy commented Aug 7, 2025 •

Copy link
Copy Markdown
Contributor Author

@allroundexperts I've already activated an Expensify CardFeed for current workspace long time ago. After that I run Onyx.merge

@thelullabyy

Copy link
Copy Markdown
Contributor Author

@Pujan92 My proposal updates card feed based on defaultFundId and i think this is reasonable. Thanks for your suggestion but I don't have an account setup with enough cardFeed like you to be able to check is there any regression if apply it.

@Pujan92

Pujan92 commented Aug 7, 2025

Copy link
Copy Markdown
Contributor

@thelullabyy still I don't get why to update that on page visit which we are specifically doing on card selector updation.

To test, you can do the following steps

  1. Create a new account
  2. Create 2 workspaces
  3. Enable Expensify card for both workspaces
  4. Add a different bank account for both
  5. This way you have 2 different feeds and invite new members to the workspace to issue new cards for them

@thelullabyy

Copy link
Copy Markdown
Contributor Author

@Pujan92 I stuck on verify bank account step when issue new card. And can you clarify more why lastSelectedExpensifyCardFeed_ is updated on refresh?

Screenshot 2025-08-08 at 15 26 18

@Pujan92

Pujan92 commented Aug 10, 2025

Copy link
Copy Markdown
Contributor

@Pujan92 I stuck on verify bank account step when issue new card.

I also faced this earlier, but using a different bank account id for both workspaces solved it for me.

And can you clarify more why lastSelectedExpensifyCardFeed_ is updated on refresh?

As lastSelectedExpensifyCardFeed_ can be missing, it seems that before retrieving the actual data of lastSelectedExpensifyCardFeed it is logged as undefined, so useDefaultFundID returns the workspaceAccountID initially and your changes update that value.

@thelullabyy

thelullabyy commented Aug 15, 2025 •

Copy link
Copy Markdown
Contributor Author

@Pujan92 Make sense to me. But will have any affect with my proposal since we decided to choose the simpler solution

@thelullabyy

thelullabyy commented Aug 20, 2025 •

Copy link
Copy Markdown
Contributor Author

@allroundexperts Do you have any thought for this?

@thelullabyy

Copy link
Copy Markdown
Contributor Author

@allroundexperts bump in this ^

@allroundexperts

Copy link
Copy Markdown
Contributor

@thelullabyy I am trying to get the workspace ready. Asking for help in the C+ channel.

@Pujan92

Pujan92 commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

@Pujan92 Make sense to me. But will have any affect with my proposal since we decided to choose the simpler solution

@thelullabyy have you checked this? Isn't that look more straightforward and correct?

@thelullabyy

Copy link
Copy Markdown
Contributor Author

@Pujan92 Yeah but i'm not sure it cause regression or not. I would like to consult @allroundexperts

@allroundexperts

Copy link
Copy Markdown
Contributor

@thelullabyy If you agree with the solution provided by @Pujan92, let's maybe use there solution and we split the compensation?

@thelullabyy

Copy link
Copy Markdown
Contributor Author

I reviewed @Pujan92 ’s solution again, and I believe this is intentional rather than a mistake. The domain fundID should be different from the workspace accountID so that multiple funds within the same workspace can be distinguished.

([key, settings]) => settings?.preferredPolicy && settings.preferredPolicy === policyID && !key.includes(workspaceAccountID.toString()),

For my solution, I still align with it. Regarding this comment, we can add a check only to call updateSelectedExpensifyCardFeed if lastSelectedExpensifyCardFeed is undefined

cc @koko57 Because you are the author of this feature

@koko57

koko57 commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

I don't remember mvery well but I don't agree with this one:
We have an incorrect condition of matching !key.includes(workspaceAccountID.toString()) to derive domainFundID in useDefaultFundID, which finds the wrong cardSettings item.

If we didn't have this condition domainFundID would be the same as workspaceAccountID, right?
so the rest of the code in this hook would be redundant - I mean this part

if (domainFundID) {
        return domainFundID;
    }

    if (workspaceAccountID) {
        return workspaceAccountID;
    }

I don't remember why we wanted to differentiate between them, but it was intentional like @thelullabyy says

@Pujan92

Pujan92 commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

If we didn't have this condition domainFundID would be the same as workspaceAccountID, right?

Ah, Ok. Thanks @thelullabyy and @koko57 for the info.

Then I think we should change the order of condition bcoz I believe workspaceAccountID should have more weightage to be a default fund id, if it is not available then we can consider the other fund id with domainFundID.

    if (workspaceAccountID) {
        return workspaceAccountID;
    }

    if (domainFundID) {
        return domainFundID;
    }

@koko57

koko57 commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

If we didn't have this condition domainFundID would be the same as workspaceAccountID, right?

Ah, Ok. Thanks @thelullabyy and @koko57 for the info.

Then I think we should change the order of condition bcoz I believe workspaceAccountID should have more weightage to be a default fund id, if it is not available then we can consider the other fund id with domainFundID.

    if (workspaceAccountID) {
        return workspaceAccountID;
    }

    if (domainFundID) {
        return domainFundID;
    }

I wonder why out of a sudden the IDs got mixed up with other workspaces? 🤔 If I understand correctly the whole issue.

@allroundexperts

Copy link
Copy Markdown
Contributor

Hi @thelullabyy,
Can you please merge main?

I'll reach out to you tomorrow morning for the creds.

@thelullabyy

Copy link
Copy Markdown
Contributor Author

@allroundexperts updated

@dangrous

Copy link
Copy Markdown
Contributor

did we figure out how to test this one successfully @allroundexperts ?

@allroundexperts

Copy link
Copy Markdown
Contributor

Replied in the slack thread @dangrous

@dangrous

Copy link
Copy Markdown
Contributor

Seems like maybe we should re-add the same bank account, rather than using it again... Can you try that? Sort of weird, but if it works it works!

@allroundexperts

Copy link
Copy Markdown
Contributor

@dangrous

dangrous commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

Continuing the discussion in Slack, I'm having even less luck testing this than you are!

@dangrous

dangrous commented Dec 9, 2025 •

Copy link
Copy Markdown
Contributor

Just an update, we're still waiting on a software fix from our card processors to let us test this (and everything else related to test cards) again. So this may be on hold for a while

expensify.slack.com/archives/C9YU7BX5M/p1765274143039849

@dangrous

dangrous commented Dec 10, 2025 •

Copy link
Copy Markdown
Contributor

[Internal] Issue for the card thing that's blocking this is here - https://github.com/Expensify/Expensify/issues/555406#issuecomment-3625323372

@dangrous

Copy link
Copy Markdown
Contributor

@allroundexperts do you mind trying to test this one again? I believe the card issue has been fixed. If it's still not working for you, I can try as well!

@dangrous

Copy link
Copy Markdown
Contributor

Bump on testing when you can, @allroundexperts! If you're still hitting that issue with the second account, I will try too, next week.

@dangrous
dangrous requested review from Pujan92 and removed request for allroundexperts December 23, 2025 17:45
@Pujan92

Pujan92 commented Dec 23, 2025 •

Copy link
Copy Markdown
Contributor

seems preferredPolicy set of a default workspace only for other workspaces too.

Screenshot 2025-09-09 at 17 56 45

It seems now the preferredPolicy looks correct and not set to a default workspace which I mentioned above earlier. Bcoz of that, feed selector won't be shown as we will have a single feed for any specific policy.

Screenshot 2025-12-24 at 02 09 13

@Pujan92

Pujan92 commented Dec 23, 2025 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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
    • 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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • 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
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari

@Pujan92

Pujan92 commented Dec 23, 2025

Copy link
Copy Markdown
Contributor

@dangrous To replicate the issue behavior, I modified the preferredPolicy in the Onyx expensifyCardSettings to get the FeedSelector in the screen.

Current

Screen.Recording.2025-12-24.at.02.39.39.mov

With this PR

Screen.Recording.2025-12-24.at.02.41.08.mov

@Pujan92 Pujan92 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@melvin-bot
melvin-bot Bot requested a review from dangrous December 23, 2025 21:17
@dangrous
dangrous merged commit 18a0409 into Expensify:main Dec 26, 2025
4 checks passed
@OSBotify

Copy link
Copy Markdown
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 OSBotify mentioned this pull request Dec 29, 2025
53 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/dangrous in version: 9.2.88-0 🚀

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

@jponikarchuk jponikarchuk mentioned this pull request Dec 29, 2025
3 of 7 tasks
@jponikarchuk

Copy link
Copy Markdown

This PR failing because of a regression issue
This issue is reproducible in: Web

@Pujan92

Pujan92 commented Dec 30, 2025

Copy link
Copy Markdown
Contributor

@jponikarchuk that isn't a regression and same behaviour in prod too. @dangrous this is something I highlighted here

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.2.88-7 🚀

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

@jponikarchuk

Copy link
Copy Markdown

@Pujan92 You are right. This issue is reproducible in Prod too

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants