Skip to content

Filter hidden Account Managers from search From filter and scope to workspace members#84376

Open
MelvinBot wants to merge 4 commits intomainfrom
claude-filterHiddenAMsFromSearchFilters
Open

Filter hidden Account Managers from search From filter and scope to workspace members#84376
MelvinBot wants to merge 4 commits intomainfrom
claude-filterHiddenAMsFromSearchFilters

Conversation

@MelvinBot
Copy link
Contributor

Explanation of Change

Account Managers (AMs) are added as "hidden" members of managed customer workspaces with notificationPreference: 'hidden'. They should be invisible to the customer, but were appearing in the "From" filter on the Reports/Search page. To match Classic behavior, this PR:

  1. Excludes hidden participants from report-based optionsprocessReport in OptionsListUtils now passes shouldExcludeHidden=true to getParticipantsAccountIDsForDisplay, consistent with other call sites at lines 1123 and 1184 that already pass true.

  2. Scopes the From filter to workspace members only — Adds a shouldScopeToWorkspaceMembers prop to SearchFiltersParticipantsSelector that collects all workspace member accountIDs across the user's policies via getMemberAccountIDsForWorkspace and filters the personalDetails suggestions to only those members.

  3. Enables free text email input in the From filter — When shouldScopeToWorkspaceMembers is enabled, the component allows users to type arbitrary emails that aren't in the suggestion list, matching Classic's behavior. The userToInvite option is included in sections so typed emails appear as selectable entries.

Fixed Issues

$ #83879
PROPOSAL: #83879 (comment)

Tests

  1. Log in and navigate to the Reports/Search page
  2. Click the "From" filter (or navigate to advanced filters > From)
  3. Verify only workspace members appear in the suggestions (no Account Managers or random contacts)
  4. Type an arbitrary email like test@example.com in the search field
  5. Verify a selectable option appears for the typed email
  6. Select the typed email and verify it's added as a selected filter
  7. Click "Save" and verify the filter is applied
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline and open the From filter
  2. Verify previously loaded workspace members still appear from cached data
  3. Verify the filter works as expected when no network is available

QA Steps

  1. Log in as a managed customer (one who has an Account Manager assigned to their workspace)
  2. Navigate to the Reports page > click the "From" filter
  3. Verify the Account Manager does NOT appear in the filter suggestions
  4. Verify workspace members DO appear in the suggestions
  5. Type an arbitrary email in the search field and verify it appears as a selectable option
  • 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
  • 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 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
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

Tested on web — From filter shows workspace members only and accepts free text email input.

MelvinBot and others added 2 commits March 6, 2026 07:57
Account Managers added as hidden members of managed customer workspaces
were appearing in the From filter on the Reports page. This change:

1. Passes shouldExcludeHidden=true in processReport so hidden
   participants are excluded from report-based option lists
2. Adds shouldScopeToWorkspaceMembers prop to
   SearchFiltersParticipantsSelector which filters personal details
   to only workspace members across all user policies
3. Enables free text email input in the From filter so users can
   type arbitrary emails not in the suggestion list

Co-authored-by: DylanDylann <DylanDylann@users.noreply.github.com>
When allowFreeTextInput is true, include the userToInvite option
in the sections list so typed emails that don't match existing
options appear as selectable entries.

Co-authored-by: DylanDylann <DylanDylann@users.noreply.github.com>
@MelvinBot
Copy link
Contributor Author

I created this PR from an upstream branch since I don't have push access to your fork.

To take ownership of this branch and be able to push updates, run:

git remote add upstream https://github.com/Expensify/App.git
git fetch upstream claude-filterHiddenAMsFromSearchFilters
git checkout -b claude-filterHiddenAMsFromSearchFilters upstream/claude-filterHiddenAMsFromSearchFilters
git push -u origin claude-filterHiddenAMsFromSearchFilters

Then you can close this PR and open a new one from your fork.

Co-authored-by: DylanDylann <DylanDylann@users.noreply.github.com>
@MelvinBot
Copy link
Contributor Author

Fixed the failing Prettier check. The formatting issues were in src/components/Search/SearchFiltersParticipantsSelector.tsx:

  • Corrected import ordering (getMemberAccountIDsForWorkspace moved after type imports from @libs/OptionsListUtils)
  • Expanded the useMemo dependency array into multi-line format per Prettier rules

@DylanDylann
Copy link
Contributor

@MelvinBot Mark this PR as ready

@MelvinBot MelvinBot marked this pull request as ready for review March 6, 2026 08:28
@MelvinBot MelvinBot requested a review from a team as a code owner March 6, 2026 08:28
@MelvinBot
Copy link
Contributor Author

PR has been marked as ready for review.

@melvin-bot melvin-bot bot requested review from DylanDylann and removed request for a team March 6, 2026 08:28
@melvin-bot
Copy link

melvin-bot bot commented Mar 6, 2026

@DylanDylann 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]

@melvin-bot melvin-bot bot requested review from a team, inimaga and trjExpensify and removed request for a team March 6, 2026 08:28
@melvin-bot
Copy link

melvin-bot bot commented Mar 6, 2026

@inimaga 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]

@DylanDylann
Copy link
Contributor

@MelvinBot We got failed test

@DylanDylann
Copy link
Contributor

@codex review

…processReport

The processReport change to exclude hidden participants via
getParticipantsAccountIDsForDisplay(report, true) caused report 12
(thread with only hidden participants) to be dropped from OPTIONS
entirely, making the old excludeHiddenThreads subtraction incorrect.

- Add visible participant (current user) to report 11 fixture so it
  remains in the option list while still having a hidden participant
- Update 4 test assertions that previously subtracted 1 for the hidden
  thread, since it's now excluded at the processReport level

Co-authored-by: DylanDylann <DylanDylann@users.noreply.github.com>
@MelvinBot MelvinBot requested a review from a team as a code owner March 6, 2026 08:40
@MelvinBot
Copy link
Contributor Author

Fixed the failing test (job 5) check — 8 test failures in OptionsListUtilsTest.tsx.

Root cause: The processReport change to pass shouldExcludeHidden=true to getParticipantsAccountIDsForDisplay caused report 12 (a thread with only hidden participants) to be excluded from OPTIONS at the processReport level, rather than later by the excludeHiddenThreads filter. This made the test assertions that subtracted 1 for the hidden thread incorrect (double-counting the exclusion).

Fix:

  • Added the current user (accountID 2) as a visible participant to report 11 in the test fixture, so it remains in the option list while still testing the hidden participant behavior
  • Updated 4 test assertions that subtracted for the hidden thread, since it's now excluded earlier in the pipeline

@melvin-bot melvin-bot bot requested review from Gonals and removed request for a team March 6, 2026 08:41
@melvin-bot
Copy link

melvin-bot bot commented Mar 6, 2026

@Gonals 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]

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf577856f3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

}
memberIDs.add(currentUserAccountID);
return memberIDs;
}, [shouldScopeToWorkspaceMembers, allPolicies, currentUserAccountID]);

Choose a reason for hiding this comment

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

P1 Badge Recompute workspace member IDs after personal details hydrate

workspaceMemberAccountIDs is memoized without any dependency on personal details, but getMemberAccountIDsForWorkspace() resolves each member through getPersonalDetailByEmail (src/libs/PolicyUtils.ts:513). On cold start or partial Onyx hydration, policies can load before personal details, so this memo captures an incomplete member set and never refreshes, causing valid workspace members to be missing from the From filter until policies change. Include personal-details state in this memo (or derive account IDs directly from the already-available personalDetails) so the scoped list stays correct.

Useful? React with 👍 / 👎.

@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/libs/OptionsListUtils/index.ts 80.03% <100.00%> (-0.16%) ⬇️
...earchAdvancedFiltersPage/SearchFiltersFromPage.tsx 0.00% <ø> (ø)
...nents/Search/SearchFiltersParticipantsSelector.tsx 0.00% <0.00%> (ø)
... and 6 files with indirect coverage changes

@MelvinBot
Copy link
Contributor Author

I ran out of time before I could finish helping you. This usually means the task was too complex or I got stuck exploring. Please try again with a more specific request or post in the #melvinbot-ai.

Run details: https://github.com/Expensify/Expensify/actions/runs/22755517486

@DylanDylann
Copy link
Contributor

Let me check

Copy link
Contributor

@trjExpensify trjExpensify left a comment

Choose a reason for hiding this comment

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

Agreed product change in Slack, but please get videos up and test this a bunch.

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.

3 participants