Repository navigation
Description
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: Needs Reproduction (Reproduction is blocked)
Reproducible in staging?: Needs Reproduction (Reproduction is blocked)
Reproducible in production?: Needs Reproduction (Reproduction is blocked)
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: @RachCHopkins
Slack conversation (hyperlinked to channel name): #expensify_bugs
Action Performed:
Prerequisites: The account was once an admin and domain admin for a different business.
- Sign in to New Expensify
- Go to Spend > Expenses (or Reports)
- Open the “From” / “To” filter dropdown
Expected Result:
Only relevant users (current workspace/report members or former members with accessible expense/report data) for Company A/Domain A appear as filter options.
Actual Result:
Company B/Domain B users appear as selectable filter options even though the user no longer shares any workspace/reports with them (the two companies split ~2 years ago). Filtering by them returns zero results. They sometimes disappear and then reappear. Support (supportal) only sees one Company B user; the affected user sees at least 10-20
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
- Windows: Chrome
- MacOS: Chrome / Safari
Screenshots/Videos
Please check the OP for the details
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022080369081324237387
- Upwork Job ID: 2080369081324237387
- Last Price Increase: 2026-07-23
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
exfy-zapier commentedon Jul 23, 2026
This has been labelled "Needs Reproduction". Follow the steps here: https://stackoverflowteams.com/c/expensify/questions/16989
MelvinBot commentedon Jul 23, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
In Search → Spend (Expenses/Reports), the From / To filter dropdown offers stale users as selectable options — e.g. people from a business the account split from ~2 years ago (Company B) — even though the current user no longer shares any workspace, domain, or report with them. Filtering by them returns zero results, and they intermittently disappear then reappear. Supportal sees only 1 such user while the affected user sees 10–20.
What is the root cause of that problem?
The From/To filter option list is built from the entire locally-cached
ONYXKEYS.PERSONAL_DETAILS_LIST, with no filter restricting it to people the user currently shares a workspace/domain/report with.Both consumers pull from the full personal-details map:
UserSelector.tsx:47-54→usePersonalDetailSearchSelector→usePersonalDetailOptions.useAutocompleteSuggestions.ts:231-239→getSearchOptions.Both funnel into
createOptionList(PersonalDetailOptionsListUtils/index.ts:435-465), which loops over every entry inPERSONAL_DETAILS_LIST(a report/workspace link is only looked up to decorate the option, never to include/exclude it), andgetValidOptions(:264) which applies only cosmetic filters (login exists, not a domain email, not an Expensify-team/AM login, not the current user, search-term match). There is no "do we currently share anything with this account" check.Because
PERSONAL_DETAILS_LISTis populated additively viaOnyx.mergefrom many API responses and rarely pruned, historical Company B accountIDs linger in the local cache and stay selectable. The intermittent disappear/reappear and the supportal-vs-user count gap are consistent with this: a cache clear/fresh load shows fewer, then subsequent responses re-merge the stale accountIDs back in, and different accounts have accumulated different local caches.What changes do you think we should make in order to solve the problem?
Scope the personal-details option universe to accountIDs the current user actually shares a workspace/domain/report with, rather than emitting every cached entry.
getValidOptions(or upstream increateOptionList/usePersonalDetailOptions) so an option is only included when the account is a member of one of the current user's policies, shares a domain, or appears on a report the user has access to.UserSelectorpath and the inlineuseAutocompleteSuggestionspath, since they share this data source.One thing worth confirming with logs
I couldn't determine from code alone whether the backend still returns these ~10–20 Company B accountIDs in the user's
OpenApp/ReconnectApp/SearchpersonalDetailspayloads, or whether they are purely leftover local Onyx cache. Inspecting one of the affected user's request payloads for thepersonalDetailsListkeys would settle this. Either way the selectable-list bug is in App (frontend) — but if the backend is still emitting them, a backend change to stop returning unrelated accountIDs would be the more complete fix, and the frontend scoping above is still valuable as a guard.What alternative solutions did you explore? (Optional)
Pruning
PERSONAL_DETAILS_LISTwhen relationships end was considered but is riskier — personal details are legitimately shared across many surfaces (chat history, past reports), so deleting them could break unrelated UI. Scoping at the option-building layer is safer and localized.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/96862)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
ahmdshrif commentedon Jul 23, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
The Search From/To filter dropdown offers users from a company the admin split from ~2 years ago. Filtering by them returns zero results, they flap in and out of the list, and the user sees 10–20 of them while supportal sees only one.
What is the root cause of that problem?
The From/To filter renders the raw
personalDetailsListOnyx cache with no relevance gate, and that cache is append-only on the client — so anyone the account has ever interacted with stays a selectable filter option forever.The chain:
UserSelector(the component behind both the From and To filters) feeds the list straight from the fullpersonalDetailsListcollection:App/src/components/Search/FilterComponents/UserSelector.tsx
Line 30 in a4b6ddf
createOptionListturns every entry into an option — its only gate is a missingaccountID:App/src/libs/PersonalDetailOptionsListUtils/index.ts
Lines 456 to 464 in a4b6ddf
getValidOptionsonly excludes Expensify-team emails, domain emails, and the current user — there is no "does this user still share anything with me" predicate:App/src/libs/PersonalDetailOptionsListUtils/index.ts
Lines 287 to 292 in a4b6ddf
personalDetailsListis written exclusively withOnyx.merge(server onyxData and optimistic writers alike, e.g.App/src/libs/actions/PersonalDetails.ts
Line 127 in a4b6ddf
This is the structural cause: a read surface that mirrors an append-only cache. It explains every symptom detail:
All affected paths (every one renders from the same unfiltered source):
UserSelectorvia the shared filter mapping, which also routes Assignee and Attendee here (same bug):App/src/components/Search/FilterComponents/index.tsx
Lines 188 to 193 in a4b6ddf
from:/to:autocomplete builds suggestions from the same fullpersonalDetails:App/src/hooks/useAutocompleteSuggestions.ts
Lines 231 to 262 in a4b6ddf
What changes do you think we should make in order to solve the problem?
Add a relevance gate at the two convergence points, reusing the exclusion mechanism the code already has for Expensify-team members (
getExpensifyTeamExclusions→excludeFromSuggestionsOnly,App/src/components/Search/FilterComponents/UserSelector.tsx
Lines 45 to 51 in a4b6ddf
Add a sibling helper (next to
getExpensifyTeamExclusionsinPolicyUtils):A user passes the gate if they are a member of any of the admin's workspaces or a participant of any accessible report — exactly the issue's Expected Result ("current workspace/report members or former members with accessible expense/report data"): former members with still-accessible expense reports stay listed because those reports and their participants are in Onyx.
Wire it in at both surfaces:
UserSelector.tsx— merge intoexcludeFromSuggestionsOnlyat L51 (policiesis already subscribed on L34).useAutocompleteSuggestions.ts— merge into the existingmemberExclusionsat L237.Regression safety in one sentence:
excludeFromSuggestionsOnlyonly hides rows from the suggestion list — typing a full email still works viaincludeUserToInvite(L52), already-applied/saved-search values still render viashouldKeepSelectedInAvailableOptions(L57), and no other consumer ofpersonalDetailsListorgetValidOptionschanges behavior.Why the obvious spot-fix does NOT work: "just prune the stale keys out of the Onyx
personalDetailsList" fails twice. First, every write path isOnyx.merge— the next ReconnectApp/OpenApp page-in or opening any 2-year-old chat re-merges the deleted details, reproducing the exact "disappear then reappear" flapping the reporter describes. Second, nearly 200 files readpersonalDetailsListfor avatars/display names in still-accessible old chat history; deleting entries degrades those to "Hidden". The fix must be a read-side gate at the filter surfaces, not a cache mutation. (The one server-side stale user supportal sees is a backend data artifact, but a backend cleanup alone cannot fix the 10–20 entries already persisted in client caches — the App-side gate above is what actually resolves the report.)What alternative solutions did you explore? (Optional)
personalDetailsListon full reconnect (Onyx.setwith the server response) — rejected: reverted by the next merge, and it breaks name/avatar rendering across old chats.accountIDToReportIDMap— rejected: that map is built only from 1:1 DM chats (usePersonalDetailOptions.ts), so it would wrongly hide workspace members the admin never chatted with.mukhrr commentedon Jul 23, 2026
Proposal
What is the root cause of that problem?
The Search
from/tosuggestion list is a direct projection of the entirepersonalDetailsList, with no check that the current user is actually connected to those accounts.UserSelectorfeeds the whole personal details list into the selector and applies exactly one soft exclusion — Expensify staff:App/src/components/Search/FilterComponents/UserSelector.tsx
Lines 27 to 58 in a4b6ddf
The options themselves come from
createOptionList(), which emits one option per hydrated personal-detail entry unconditionally. A related report is only used to decorate an option, so having no shared report does not exclude anyone:App/src/libs/PersonalDetailOptionsListUtils/index.ts
Lines 435 to 475 in a4b6ddf
And the only exclusion helper in play matches
@expensify.com/@team.expensify.comlogins. Ordinary users retained from a former workspace or domain relationship are never excluded:App/src/libs/PolicyUtils.ts
Lines 916 to 952 in a4b6ddf
I want to correct something explicitly, because it is easy to misread the history here: this is not a regression.
getNonWorkspaceMemberExclusions(a workspace-members-only rule) was added and then replaced with the narrower Expensify-team rule inside PR #88921's own branch, so it never existed onmain—git log --first-parent -S "getNonWorkspaceMemberExclusions" origin/main -- src/libs/PolicyUtils.tsreturns nothing. The connectivity rule was deliberately scoped out of that PR, which is why this gap is still open.I reproduced this locally. On a fresh account the From filter listed only me and the one peer I share a report with. I then seeded three
@company-b.compersonal details into Onyx — no shared policy, no shared report, exactly the reported leftover state — reloaded, and all three rendered as selectable From options.This also explains the two details in the report. Because the list is a pure projection of whatever is currently hydrated, entries come and go as different API responses rehydrate personal details — matching "they sometimes disappear and then reappear". And a supportal session starts with a much smaller hydrated set than an account that has been accumulating personal details for years, which matches support seeing one Company B user while the affected user sees 10–20.
What changes do you think we should make in order to solve the problem?
I think we should add
getSearchFilterUserExclusions()toPolicyUtilsand apply it only to thefrom/tofilters, by passingfilterKeydown intoUserSelector. The helper builds an allow-list of accounts the current user is still connected to, and soft-excludes everything else:employeeList(current workspace members);ownerAccountID/managerIDof any accessible report (former members whose expense data is still searchable);participantskey of any report (1:1 DM partners and other non-workspace contacts);The last two bullets are load-bearing, and they are why I would not restore the old workspace-members-only rule.
getValidOptionsappliesexcludeFromSuggestionsOnlyto the verypersonalDetailslist thatUserSelectorrenders:App/src/libs/PersonalDetailOptionsListUtils/index.ts
Lines 392 to 413 in a4b6ddf
So a members-only rule would hide 1:1 chat partners (Search covers personal expenses and DMs, not just workspace data) and would strip an already-selected row from a saved search like
from:someone@old-co.com, so the chip would no longer render as checked. Including report participants and selected accountIDs avoids both.Scoping matters too, because the same component serves four filters:
App/src/components/Search/FilterComponents/index.tsx
Lines 188 to 202 in a4b6ddf
attendeeandassigneeare not limited to the current user's own data, so passingfilterKeylets us apply the rule tofrom/toand leave those two on the existing broad behaviour.The illustrative change in
UserSelector:The reports collection is read through a lean selector that keeps only
ownerAccountID,managerIDandparticipants, so we are not pulling full reports into a filter component.These stay suggestion-only exclusions, so
includeUserToInvitestill lets anyone type an address manually — we only stop suggesting accounts that can never match a result.I implemented and verified this. Unit tests in
PolicyUtilsTestcover a current workspace member, a former member reachable via an accessible expense report, a 1:1 participant, an unrelated stale entry, an already-selected value, and case-insensitive matching. In the browser, with the three stale entries still present in Onyx storage and the list confirmed rendered, they no longer appear in From, while the legitimate peer still does.What alternative solutions did you explore? (Optional)
I explored restoring the workspace-members-only helper from PR #88921's branch. I rejected it for the two concrete reasons above: it hides 1:1 chat partners, and because soft exclusions are applied to the rendered list it silently drops already-selected rows from saved searches.
I also considered pruning stale entries out of
personalDetailsListitself. I would avoid that — the same list backs mentions, chat and report rendering, so deleting entries risks unresolved names elsewhere; scoping the suggestion list is the narrower and safer change.melvin-bot commentedon Jul 23, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @bernhardoj (
External)wildan-m commentedon Jul 23, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
In Search (Spend > Expenses/Reports), the From / To filter dropdown offers users the account has no relationship with anymore — people from a different company/domain the account parted ways with about two years ago. Selecting one of them returns zero results. The list is also inconsistent: the entries sometimes disappear and then come back, and support (via supportal) sees only one of these accounts while the affected user sees 10–20.
What is the root cause of that problem?
The From/To filter renders
UserSelector:App/src/components/Search/FilterComponents/index.tsx
Lines 188 to 203 in 7a49ce4
and
UserSelectorbuilds its option list throughusePersonalDetailSearchSelector:App/src/components/Search/FilterComponents/UserSelector.tsx
Lines 47 to 58 in 7a49ce4
That hook gets its raw options from
usePersonalDetailOptions, which passes the wholepersonalDetailsListOnyx value intocreateOptionList:App/src/hooks/usePersonalDetailOptions.ts
Lines 151 to 159 in 7a49ce4
createOptionListthen turns every single entry of that cached list into a selectable option. It looks up a report for the account, but a missing report is not a reason to drop the entry — the option is pushed either way, just without report data:App/src/libs/PersonalDetailOptionsListUtils/index.ts
Lines 456 to 469 in 7a49ce4
The last chance to drop them is the personal-details filter inside
getValidOptions, but that filter only removes optimistic entries, domain emails, the Expensify/notifications/account-executive logins, and accounts already shown in the recent-reports bucket. There is no check for whether the current user still shares a report, workspace, or any accessible data with the account:App/src/libs/PersonalDetailOptionsListUtils/index.ts
Lines 392 to 412 in 7a49ce4
So the option list is exactly "everything that has ever been written into the local
personalDetailsListcache". That key is only ever written with merge semantics — entries are added and updated, never removed — so accounts the backend stopped returning long ago (the Company B / Domain B people) stay in the cache indefinitely and keep showing up as filter options. Because the backend search knows nothing about them, filtering by one returns zero results.This also explains the two confusing symptoms in the report. Supportal starts from a clean client state, so it only sees what the backend actually returns today (one account), while the affected user sees the accumulated local cache (10–20). And the entries "disappear and reappear" because whenever the local cache is cleared or rebuilt the stale names go away, then partially come back as older data is re-merged.
What changes do you think we should make in order to solve the problem?
Scope the personal-detail options used by the Search From/To (and the other participant filters wired to the same component: To, Assignee, Attendee) to accounts the current user actually has a relationship with, instead of the entire cached personal-details list.
Concretely:
Add an opt-in option to the options builder in
PersonalDetailOptionsListUtils— something like "only include accounts the user is related to". When it is on, the personal-details filtering function additionally requires that the account is related to the current user, meaning either the account has an associated report in the reports collection (this is already computed as the account-to-report map inusePersonalDetailOptionsand surfaces on the option as its report ID), or the account appears in theemployeeListof one of the policies the current user is a member of. Everything else in the cache is orphaned data with no report and no shared workspace — precisely the entries that produce zero search results today.Thread that option through
usePersonalDetailSearchSelectoras a new config flag, and turn it on only fromUserSelector. Keeping it opt-in means the other consumers of the same hook (invite to workspace, new chat, assign task, split participants, etc.) are untouched — those flows legitimately need to offer people you do not share anything with yet.Keep any account IDs that are already selected in the filter visible regardless of the new check, so an existing saved search or an in-progress filter never silently drops its chips.
UserSelectoralready passes the current value in as the initially selected set and asks for selected options to be kept in the available options, so this is a matter of exempting selected IDs from the new relationship check.This keeps the expected behaviour from the report intact: current workspace members and anyone you share a report with (including former colleagues whose expense/report data you can still open, because that data implies a report) continue to appear, while accounts that only exist as leftovers in the local cache stop being offered. It also keeps the fix purely on the client, where the stale data is actually being displayed.
Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/96862-scope-search-participant-filter?expand=1
What alternative solutions did you explore? (Optional)
Prune the cached personal-details list instead of filtering at render time. Rather than scoping the filter, we could reconcile
personalDetailsListon app open so accounts that the backend no longer returns are deleted from the local cache. This would fix the symptom everywhere at once, but it is much riskier: the key is written with merge semantics on purpose, many flows depend on holding on to personal details for accounts whose reports are not currently loaded, and deleting entries that were merely absent from a partial response would make names render as unknown across the app. The relationship check at the option-building layer is the narrower and safer change.Filter only by the presence of a report ID on the option. This is a one-line version of the same idea, but it would wrongly hide workspace members you have not started a chat with, so it needs the policy
employeeListhalf as well.10 remaining items
github-actions commentedon Jul 24, 2026
Dip-G-Git commentedon Jul 24, 2026
Proposal
Reviewing the code and preparing a detailed root-cause analysis — this comment will be updated with the full proposal shortly.
nabi-ebrahimi commentedon Jul 24, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-07-24 10:45:59 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
The Spend
FromandTofilters suggest users who have no relevant expenses or reports accessible to the current user. Selecting one produces zero search results.What is the root cause of that problem?
From,To,Assignee, andAttendeeshare the genericUserSelectorcomponent.UserSelectorbuilds its options from the completePERSONAL_DETAILS_LISTviacreateOptionList(), which creates an option for every personal detail with anaccountID.getValidOptions()applies only generic exclusions — no Spend-specific relevance check exists.The critical distinction from prior proposals:
FromandToare not symmetric filters, and they do not share the same candidate set. Search derives them from different roles that do not map toreport.participants:From(SearchUIUtils.ts:2145):reportAction?.actorAccountID ?? report?.ownerAccountID— the money-request action actor, falling back to report owner.From(SearchUIUtils.ts:2966):report.ownerAccountID.To(SearchUIUtils.ts:1708-1726): ForPAYactions, the report owner. For IOUs, the payer/receiver selected bygetIOUPayerAndReceiverbased on amount sign. Otherwise,report.managerID.A single "users who share a report or workspace" gate is therefore incorrect: it includes arbitrary chat participants who have no From/To value in any accessible Spend result, while excluding owners/managers who are valid filter values but absent from
report.participants.What changes do you think we should make in order to solve the problem?
Create a Search-specific helper that derives suggestion exclusions with separate candidate sets for
FROMandTO.Common allowed accounts (both From and To):
getMemberAccountIDsForWorkspace).From-specific allowed accounts:
ownerAccountIDfrom accessible Expense, IOU, and Invoice reports.actorAccountIDfrom money-request actions, when Search uses the actor as the transaction's From value.To-specific allowed accounts:
managerIDfrom accessible Spend reports.getIOUPayerAndReceiverdirection logic.PAYactions.Return an exclusion map via
excludeFromSuggestionsOnly— notexcludeLogins— so already-selected values remain and users can enter an exact email manually.Apply to both surfaces:
UserSelector(RHP panel).from:andto:keys in the search bar.Pass
filterKeytoUserSelectorand enable this only forFROMandTO. Do not changeAssignee,Attendee,Payer,Exporter, invitation, or IOU participant selectors.Use lean Onyx selectors and memoize derived sets. Place the helper in a Search-specific module (e.g.,
SearchUserFilterUtils), notPolicyUtils.What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
report.participantsappears in From.report.participantsappears in To.PAYaction renders the report owner as To, not the manager.What alternative solutions did you explore? (Optional)
A single "users related to the current user" exclusion gate (workspace members + report participants) is simpler but incorrect. It includes arbitrary chat participants who have no From/To value in Spend results while excluding report owners and managers who are valid filter values but absent from
report.participants. The role-specific FROM/TO candidate separation is required to match the actual search rendering logic.Pruning
PERSONAL_DETAILS_LISTis unsafe because it is shared state used by chat, IOU, invitation, and other features. The available evidence does not prove the cache contents are invalid.A backend-provided list of valid From/To facets would be most authoritative and would handle incomplete client hydration, but requires an API change. The proposed role-based projection is a smaller fix structured so server-provided facets can replace it later.
github-actions commentedon Jul 24, 2026
x-dev90 commentedon Jul 24, 2026
Proposal
What is the root cause of that problem?
The
FromandTofilters (along withAssigneeandAttendee) all render the sameUserSelectorcomponent, and it builds its option list from the entire client-sidePERSONAL_DETAILS_LISTwith no check for whether the account still shares a workspace or report with the current user.UserSelectorsources its options fromusePersonalDetails()— the wholePERSONAL_DETAILS_LIST— and passes it into the search selector, requesting only Expensify/system-email exclusions. There is no accessibility scoping here:App/src/components/Search/FilterComponents/UserSelector.tsx
Lines 30 to 58 in 4bb1d01
That list is produced by
createOptionList, which turns every personal-details entry that has anaccountIDinto a selectable option — a shared report is only attached to enrich the option, never used to drop an account that shares nothing:App/src/libs/PersonalDetailOptionsListUtils/index.ts
Lines 456 to 469 in 4bb1d01
getValidOptionsthen filters that list, but only removes entries with no login/accountID, optimistic details, domain emails, the account-executive logins, and search-term mismatches. It never checks shared policy or report membership:App/src/libs/PersonalDetailOptionsListUtils/index.ts
Lines 392 to 411 in 4bb1d01
So the causal chain is: the client's
PERSONAL_DETAILS_LISTretains accounts encountered in the past (the Company B / Domain B users from before the split ~2 years ago) and is never pruned →createOptionListmakes an option for each of them →getValidOptionshas no shared-workspace/report rule to drop them → they render as selectableFrom/Tooptions even though the user shares no workspace or report with them, and filtering by them returns zero results because there is no accessible data. This is longstanding behavior (the option-building loop was last touched by a general refactor in #83310, not introduced as a regression). It also explains why supportal, on a fresh session, sees only the one still-shared Company B user while the affected user — whose local Onyx cache has accumulated stale accounts — sees 10–20.What changes do you think we should make in order to solve the problem?
Approach: scope the
From/Tooption list to accounts the current user still has a relationship with — members of any policy the user belongs to, plus participants of any report available to the user — while always keeping any accountIDs already present in the applied filter value. This matches the Expected Result (current workspace/report members and former members with accessible expense/report data) and drops accounts, like the split-off Company B users, that share neither.Implementation: in
UserSelector, derive an "accessible accountID" set from data already synced on the client — policy member accountIDs viagetMemberAccountIDsForWorkspaceover the policies the current user belongs to, plus participant accountIDs from the reports in theREPORTcollection the user can access — then restrict the rendered personal-details options to accountIDs in that set, unioned with theinitialSelectedAccountIDsalready computed in the component so saved-search chips keep rendering. BecauseUserSelectoris the single component behind theFrom,To,Assignee, andAttendeefilters, this fixes all four consistently. The set is derived purely from already-synced Onyx data, so it works offline with no new API calls.Regression test: render the
Fromfilter with aPERSONAL_DETAILS_LISTthat contains an account which is neither a member of any of the current user's policies nor a participant in any accessible report, and assert it does not appear as an option; assert that an account sharing a policy or report does appear; and assert that an accountID already present in the filter value still renders even when it shares neither.What alternative solutions did you explore? (Optional)
Prune stale entries from
PERSONAL_DETAILS_LISTitself. The evidence (supportal on a fresh session sees only one Company B user, and the entries "disappear and reappear") points to the client cache accumulating accounts that are never cleaned up, so fixing the data at the source would help every surface, not just this filter. Trade-off: deciding which accounts are safe to drop and how they re-hydrate is a data-layer/backend concern that is larger and riskier than a targeted filter, and it must still retain former-but-accessible members, so it does not remove the need for correct scoping in the selector.Add an accessibility-scoping option to
getValidOptions/usePersonalDetailSearchSelectorand opt the search filter into it. Trade-off: reusable for other selectors, but it changes a shared util used by many flows (IOU participant pickers, member invites) that intentionally show the full contact list, increasing the regression surface versus keeping the logic local toUserSelector.github-actions commentedon Jul 24, 2026
nabi-ebrahimi commentedon Jul 24, 2026
This proposal is distinct from ahmdshrif's in three specific ways:
SearchUIUtils.ts:2145derives From fromactorAccountID ?? ownerAccountID, whileSearchUIUtils.ts:1708-1726derives To frommanagerID/ IOU direction / PAY action owner — different roles, different users.report.participants. A report owner (ownerAccountID) is often absent fromparticipantsbut is a valid From value. This proposal keys onownerAccountID,managerID,actorAccountID, and IOU direction logic instead.reportAction.actorAccountIDat line 2145) or the PAY-action special case where To becomes the owner (line 1708), not the manager.melvin-bot commentedon Jul 28, 2026
@bernhardoj Eep! 4 days overdue now. Issues have feelings too...
yusufdeveloper2903 commentedon Jul 29, 2026
Proposal
What is the root cause of that problem?
The "From" / "To" (and Assignee / Attendee) advanced filter is rendered by
UserSelector, which every one of those filter keys maps to:App/src/components/Search/FilterComponents/index.tsx
Lines 188 to 204 in a4b6ddf
UserSelectorbuilds its option pool fromusePersonalDetails(), which is bound directly to the OnyxPERSONAL_DETAILS_LISTcollection — OnyxListItemProvider.tsx:13. That map is then fed throughusePersonalDetailSearchSelector→usePersonalDetailOptions→createOptionList(accountID, personalDetails, …), which turns every entry in the map into a selectable option. The only entry it skips is one missing anaccountID:App/src/libs/PersonalDetailOptionsListUtils/index.ts
Lines 456 to 469 in a4b6ddf
The
accountIDToReportIDMap/reportsarguments here are used only to decorate an option with a report for display — they are not a membership gate. A user you no longer share any report with simply getsreportID = undefinedand is still pushed into the list.Downstream,
getValidOptionsfilters that pool, but not by relevance. Its personal-detailsfilteringFunctiondrops an entry only when it has nologin/accountID, is an optimistic detail, is a domain email, is an account-executive login, is a recent-report duplicate, is an explicitly-excluded login (the Expensify-team loginsUserSelectorpasses), or fails the search string:App/src/libs/PersonalDetailOptionsListUtils/index.ts
Lines 392 to 411 in a4b6ddf
There is no check for whether the account still shares a current workspace or an accessible report with the viewer.
UserSelectorcompounds this by passingincludeRecentReports: false, so the list is never even scoped to people you have recent reports with.Why the stale accounts are still in the cache to begin with:
PERSONAL_DETAILS_LISTis not an evictable Onyx key — setup/index.ts:41-47 lists only report-action collections — and member removal never writesPERSONAL_DETAILS_LIST(removeMemberstouchesemployeeList, reports and room members only). So once a personal detail is seeded from an old workspace/domain relationship, it lives in the local cache indefinitely — including the Company B / Domain B users from ~2 years ago — and each one is offered as a filter option.This matches the report precisely: filtering by these accounts "returns zero results" because they share no accessible report/transaction with the user, and supportal — reading the server's authoritative data — sees only the one still-relevant Company B account, while the client's stale cache surfaces 10-20. The intermittent disappear/reappear is consistent with an
OpenApp/ReconnectApprefresh momentarily dropping entries the backend no longer returns, then those same accountIDs being re-seeded from still-cached reports that reference them — but the stable defect is the missing relevance gate above.What changes do you think we should make in order to solve the problem?
The mention suggester already builds its list from the same
PERSONAL_DETAILS_LIST, and in a workspace/group context it keys relevance on the exact two predicates the From/To filter is missing —policy.employeeList[detail.login]andisReportParticipant(detail.accountID, currentReport):App/src/pages/inbox/report/ReportActionCompose/SuggestionMention.tsx
Lines 345 to 369 in a4b6ddf
We should apply that same membership relevance to the From/To filter, as a hard gate rather than a weight. Concretely:
In
UserSelector, compute the set of accountIDs the viewer still shares data with — members of every policy inpolicies(viagetMemberAccountIDsForWorkspace) unioned with the participants of the reports the client has access to — and pass it as a new optionalrelevantAccountIDsconfig tousePersonalDetailSearchSelector.Thread
relevantAccountIDsinto thegetValidOptionscall (base.ts:215-231) and add one clause to the personal-detailsfilteringFunction:Only
UserSelectorpassesrelevantAccountIDs; when it is omitted the filter behaves exactly as today.This is safe because:
UserSelectorpassesshouldKeepSelectedInAvailableOptions: trueand the new clause exemptsisSelected, so a stale account you have already selected as a filter is never removed from the list.includeUserToInvite: truebuilds theuserToInviteoption independently of the personal-detailsfilteringFunction, so you can still enter any email/phone that isn't in the suggestion set.relevantAccountIDs, so their intentionally-broad contact lists are unchanged.policy.employeeListmembership + report participation) are already trusted for this exact purpose in the mention suggester.Note: the relevance set must be the union of report participation and policy membership, not the narrow
accountIDToReportIDMapthatusePersonalDetailOptionsalready computes — that map is built from only 1:1 chats and self-DMs, so reusing it would wrongly drop legitimate From/To candidates you share an expense report or a workspace with but no 1:1 chat. A former member with accessible expense/report data still appears because they remain a participant of a report the client can access.We can also apply the same relevance set to the typed
from:/to:autocomplete, which draws from the same unfiltered pool throughSearchAutocompleteList→OptionsListUtils.getSearchOptions.What alternative solutions did you explore? (Optional)
Purge
PERSONAL_DETAILS_LISTwhen a member/domain relationship ends (evict the key or clear entries inremoveMembers). Rejected: it cannot retroactively clean the reporter's already-stale cache (2 years of accumulated entries), the personal detail is still legitimately needed to render historical reports/transactions that reference the accountID, and the observed flicker shows entries get re-seeded from those references anyway. The filter should present a relevance-bounded list regardless of what the local cache happens to hold.github-actions commentedon Jul 29, 2026
trjExpensify commentedon Jul 29, 2026
Closing in favour of an improvement.