Skip to content

[$250] Deleted workspace still visible in recipient list when creating an expense via FAB #74170

Closed

Description

@mitarachim

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.2.43-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #72871
Email or phone of affected tester (no customers): poipio514+employee1@gmail.com
Issue reported by: Applause Internal Team
Device used: Windows 11 / Chrome, iPhone 13 / Safari
App Component: Money Requests

Action Performed:

Preconditions:

  1. Login with any account that has an invited workspace
  2. Delete all existing workspaces and leave from any invited workspace, so there will be a "you have no workspace" modal displayed in workspace tab.

Steps:

  1. Refresh the page
  2. Click FAB > Click "create expense"
  3. Enter any amount > click "next"
  4. Observe the recipient list -> there's a deleted workspace displayed
  5. Click on the workspace
  6. Enter the merchant and click "create ... expense"

Expected Result:

The deleted workspace shouldn't be visible in recipient list, like in mobile app version do. Also, if user click on the deleted expense as recipient, it should be trigger an error.

Actual Result:

The deleted expense is visible in recipient list and when user try to select it as recipient, user is navigated to self DM and the expense is created in self DM.

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

Bug6993491_1762245743401.deleted_workspace.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021985812442777928560
  • Upwork Job ID: 1985812442777928560
  • Last Price Increase: 2025-11-11

Activity

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

    @melvin-bot

    Triggered auto assignment to @Christinadobrzyn (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. mitarachim commented on Nov 4, 2025

    @mitarachim
    Author

    Issue was found while executing QA for PR #72871

  4. abbasifaizan70 commented on Nov 4, 2025

    @abbasifaizan70
    Contributor

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

    When creating an expense, deleted workspaces are still appearing in the recipient list. When a user selects a deleted workspace as a recipient, they are navigated to their self DM and the expense is created there instead of showing an error.

    Expected Result:

    • The deleted workspace shouldn't be visible in recipient list (like in mobile app version)
    • If user clicks on the deleted workspace as recipient, it should trigger an error

    Actual Result:

    • The deleted workspace is visible in recipient list
    • When user tries to select it as recipient, user is navigated to self DM and the expense is created in self DM

    What is the root cause of that problem?

    The isValidReport function in src/libs/OptionsListUtils/index.ts doesn't check if a policy expense chat's associated policy is deleted or pending deletion. When a workspace is deleted, its policy gets pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, but the expense chat reports associated with that policy can still exist in the reports collection. The validation logic filters based on report properties but doesn't validate the policy status.

    The shouldShowPolicy utility function exists to check if a policy should be displayed (excluding deleted policies when shouldShowPendingDeletePolicy is false), but it's not being used in the isValidReport function when validating policy expense chats.

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

    Add a check in the isValidReport function to filter out policy expense chats whose associated policies are deleted or pending deletion. This will ensure deleted workspaces don't appear in the recipient list, matching the mobile app behavior.

    Changes Made

    File: src/libs/OptionsListUtils/index.ts

    1. Add shouldShowPolicy to the imports from @libs/PolicyUtils
    2. Add validation in isValidReport function to check if policy expense chat's policy is deleted
    diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts
    index abc123..def456 100644
    --- a/src/libs/OptionsListUtils/index.ts
    +++ b/src/libs/OptionsListUtils/index.ts
    @@ -28,6 +28,7 @@ import {
         getCountOfRequiredTagLists,
         getSubmitToAccountID,
         isCurrentUserMemberOfAnyPolicy,
    +    shouldShowPolicy,
     } from '@libs/PolicyUtils';
     import {
         getChangedApproverActionMessage,
    @@ -1722,6 +1723,13 @@ function isValidReport(option: SearchOption<Report>, config: IsValidReportsConf
         if (isPolicyExpenseChat && !includeOwnedWorkspaceChats) {
             return false;
         }
    +
    +    // Filter out policy expense chats whose policies are deleted or pending deletion
    +    if (isPolicyExpenseChat && option.policyID) {
    +        const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${option.policyID}`];
    +        if (!shouldShowPolicy(policy, false, currentUserLogin)) {
    +            return false;
    +        }
    +    }
    +
         // When passing includeP2P false we are trying to hide features from users that are not ready for P2P and limited to expense chats only.
         if (!includeP2P && !isPolicyExpenseChat) {
             return false;

    What alternative solutions did you explore? (Optional)

    1. Filter at the report level: Checked if we could filter deleted policies when building the reports list, but the filtering needs to happen at the option validation level since reports can exist independently of their policy status.

    2. Validation in MoneyRequestParticipantsSelector: Considered adding validation in the component, but the proper place is in isValidReport since this ensures deleted workspaces don't appear in any recipient selection scenario, not just expense creation.

    3. Using isPendingDeletePolicy directly: Instead of shouldShowPolicy, we could check policy?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, but shouldShowPolicy provides a more comprehensive check that also handles edge cases like policies with errors.

  5. Christinadobrzyn commented on Nov 4, 2025

    @Christinadobrzyn
    Contributor

    @lakchote @ZhenjaHorbach @LukasMod It looks like this was found while executing the QA of #72871

    Does that mean that you should work on the fix? I don't think that necessarily means a regression, correct?

  6. ZhenjaHorbach commented on Nov 4, 2025

    @ZhenjaHorbach
    Contributor

    @lakchote @ZhenjaHorbach @LukasMod It looks like this was found while executing the QA of #72871

    Does that mean that you should work on the fix? I don't think that necessarily means a regression, correct?

    I don't think this is an issue with our PR
    We just fixed the issue with using negative values

  7. Christinadobrzyn commented on Nov 4, 2025

    @Christinadobrzyn
    Contributor

    I can reproduce this on iOS following the steps in the OP. Adding External.

  8. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Nov 4, 2025
  9. changed the title [-]Deleted workspace still visible in recipient list when creating an expense via FAB[/-] [+][$250] Deleted workspace still visible in recipient list when creating an expense via FAB[/+] on Nov 4, 2025
  10. melvin-bot commented on Nov 4, 2025

    @melvin-bot
  11. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Nov 4, 2025
  12. melvin-bot commented on Nov 4, 2025

    @melvin-bot

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

  13. IjaazA commented on Nov 5, 2025

    @IjaazA
    Contributor

    Proposal

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

    When creating an expense after deleting all workspaces, deleted workspaces still appear in the recipient list on web.

    What is the root cause of that problem?

    The isValidReport function in src/libs/OptionsListUtils/index.ts did not handle deleted policy expense chats.
    There was no validation in addParticipant (in src/pages/iou/request/step/IOURequestStepParticipants.tsx) to prevent selecting deleted workspaces.

    As a result, deleted workspaces were still being treated as valid options, leading to invalid navigation and expense creation.

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

    Filter deleted workspaces from the recipient list
    Update isValidReport to exclude policy expense chats from deleted workspaces.
    Use the isPendingDeletePolicy utility to check if the workspace is deleted.
    Prevent such workspaces from being shown in the recipient list.

    if (isPolicyExpenseChat && option.policyID) {
        const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${option.policyID}`];
        if (isPendingDeletePolicy(policy)) {
            return false;
        }
    }
    

    Add validation for deleted workspace selection
    In addParticipant, add a check to determine if the selected workspace is deleted.
    If it is, display an error message instead of navigating or creating an expense.
    Maintain a state to track and display this error.
    Add a translation key for the error message
    Added workspace.common.deletedWorkspaceError in src/languages/en.ts:
    "This workspace has been deleted and cannot be used for expenses."

    What alternative solutions did you explore? (Optional)

    • Report-level filtering: Less reliable since it doesn’t prevent invalid selections early.
    • Using getActivePolicies: Not suitable for this specific filtering logic in the options list.
    • Only filtering without defensive validation: Would not handle edge cases where deleted workspaces might still be selected programmatically.
  14. brunovjk commented on Nov 6, 2025

    @brunovjk
    Contributor

    It's on my list. Reviewing ASAP.

  15. Christinadobrzyn commented on Nov 11, 2025

    @Christinadobrzyn
    Contributor

    Hi @brunovjk just checking on this to see if you have any update!

  16. melvin-bot commented on Nov 11, 2025

    @melvin-bot

    📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

  17. brunovjk commented on Nov 12, 2025

    @brunovjk
    Contributor

    @Christinadobrzyn I can't reproduce it:

    iOS: HybridApp - Latest main (12 Nov - v9.2.54-1 Develop)
    Screen.Recording.2025-11-12.at.11.02.15.mov
    MacOS: Chrome / Safari - Staging (v9.2.54-1)
    Screen.Recording.2025-11-12.at.11.05.59.mov

    Can you still? Apologies for the delay. Thank you.

  18. Christinadobrzyn commented on Nov 13, 2025

    @Christinadobrzyn
    Contributor
  19. m-natarajan commented on Nov 13, 2025

    @m-natarajan

    Not repro, Windows 11 / Chrome v9.2.57-0

    left.ws.mp4
  20. Christinadobrzyn commented on Nov 13, 2025

    @Christinadobrzyn
    Contributor

    sounds like this is not reproducible. I think this can be closed? @brunovjk did you do any work here?

  21. brunovjk commented on Nov 13, 2025

    @brunovjk
    Contributor

    sounds like this is not reproducible. I think this can be closed? @brunovjk did you do any work here?

    Great! Nothing special, I'm just testing and trying to reproduce.

  22. Christinadobrzyn commented on Nov 13, 2025

    @Christinadobrzyn
    Contributor

    Ok sounds good, I'm going to close. Thank you!

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions