App icon indicating copy to clipboard operation
App copied to clipboard

[$175] Search - Workspace admin (reimburser/approver) cannot find or open a report in their workspace that another member can find

Open m-natarajan opened this issue 2 weeks ago • 13 comments

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


Version Number: Reproducible in staging?: Needs Reproduction Reproducible in production?: Needs Reproduction 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: @sofiainteriano Slack conversation (hyperlinked to channel name): #Expensify Bugs

Description:

User A is trying to view report Report X in workspace WS A, but it doesn't appear in her report search. User B can find and open the same report. Both users are associated with the same workspace, and User A is configured as its reimburser and approver. She also has full report permissions on another report in the workspace, so this doesn't look like a general workspace-access problem.

Action Performed:

  1. Log in as User A and search for report Report X.
  2. Observe that the search returns no results.
  3. Log in as User B and search for the same report.
  4. Observe that the report is found and opens successfully.

Expected Result:

User A should be able to find and open the report, because it belongs to her workspace and her role (reimburser/approver) should give her access, consistent with the workspace's permissions.

Actual Result:

User A cannot find or view the report. User B can find and open it.

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • [ ] Android: App
  • [ ] Android: mWeb Chrome
  • [ ] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [x] MacOS: Chrome / Safari

Screenshots/Videos

The screenshot for the issue is in Slack thread

View all open jobs on GitHub

Upwork Automation - Do Not Edit

m-natarajan avatar Nov 17 '26 21:11 m-natarajan

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

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

Issue Analysis

⚠️ Preliminary analysis (low confidence) — the root cause is not yet established.

Working hypothesis: User A’s report-specific permissions or search scope differ from User B’s. The current evidence does not distinguish an access problem from a search-filtering problem.

Findings

  • Approver/reimburser does not establish Workspace Admin status. App checks the admin role separately from approval assignments. Access to another report does not establish access to Report X.
  • Missing from search does not prove inaccessible. Approve and Pay searches include account-specific restrictions. Opening the exact report link makes a separate request.
  • Draft status alone would not explain the issue. The help documentation says Workspace Admins and the report’s workflow approvers can view drafts in Spend > Reports, although drafts do not appear in the approval queue.
Code evidence

These establish possible mechanisms, not which mechanism affected Report X.

Evidence needed to confirm

  1. Record User A’s result when opening the exact report URL that works for User B, online.
  2. Compare the same unrestricted Spend > Reports search, including the full query and filters.
  3. Verify User A’s actual workspace role, Report X’s workspace/status, and its approval workflow.
  4. Internally capture the affected account/report/workspace IDs, reproduction timestamp, and search/direct-open responses.

Diagnostic boundary: If the server returns Report X but the UI omits it, investigate App filtering/state. If the server omits or denies it despite verified entitlement, an internal engineer needs to investigate server-side behavior.

Blocker: The public issue contains only placeholder identifiers, no direct-link result, and no confirmed reproduction. The linked internal evidence was unavailable in this run. No issue-specific fix is verified.


Next Steps: Reply with @MelvinBot <your feedback> to refine this analysis.


view run

MelvinBot avatar Nov 17 '26 21:11 MelvinBot

Proposal

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

A workspace admin (configured as approver and reimburser) cannot search for or find an active expense report in her workspace, even though other workspace members can search, find, and view it.

What is the root cause of that problem?

In Search / report indexing logic (src/libs/SearchUtils.ts or src/libs/ReportUtils.ts), report search results check direct participant status (report.participantAccountIDs or report.ownerAccountID === currentUserAccountID) rather than verifying if the current user possesses workspace-level management roles (PolicyUtils.isPolicyAdmin(policy) or role as reimburser/approver for the associated policyID). Consequently, when a report belongs to the workspace but has not yet been directly routed or assigned to the admin's specific step, client-side search visibility filters out the report for the admin.

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

  1. In src/libs/SearchUtils.ts (or the relevant search report filter function canUserPerformWriteAction / shouldShowReportInSearch), expand the visibility predicate to check if currentUserAccountID is a workspace admin, reimburser, or default approver for report.policyID.
  2. Ensure that workspace reports with matching policyID are included in the search list query evaluation when the active user has approver/reimburser privileges for that workspace.

What alternative solutions did you explore?

Granting blanket access to all workspace reports, but scoping strictly by verifying isPolicyAdmin and isApprover/isReimburser in PolicyUtils preserves proper role-based access control and security boundaries.

zainrizvi0611-cmd avatar Nov 18 '26 04:11 zainrizvi0611-cmd

📣 @zainrizvi0611-cmd! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

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

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

zainrizvi0611-cmd avatar Nov 18 '26 05:11 zainrizvi0611-cmd

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

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

@abdulrahuman5196 Friendly bump on this when you have a moment to review the proposal! Contributor details are verified and solution is ready to proceed. Thanks!

zainrizvi0611-cmd avatar Nov 19 '26 18:11 zainrizvi0611-cmd

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

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

Proposal

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

In a workspace, an admin who is the reimburser and approver searches for an expense report that belongs to the workspace, and the search returns no results, while another member can find and open the same report. The admin has full report permissions on another report in the same workspace, so this is not a general workspace-access problem: the report is findable for one user and invisible in search for another.

What is the root cause of that problem?

Local report search drops money request reports whose participants map is empty, even though the report's people are known through ownerAccountID (submitter) and managerID (approver).

Money request reports do not record their people in participants the way chats do. The submitter lives in ownerAccountID and the approver in managerID, and isReportParticipant already treats those two as participants for access checks. The participants map itself is not a reliable source of people for these reports: search-shaped payloads routinely omit it to keep payloads small (the codebase says so in reasonForReportToBeInOptionList), and the repo's own fixtures build expense reports with no participants at all.

Two gates in src/libs/OptionsListUtils/index.ts treat an empty participants list as "this report has no people" and drop the report from search:

  1. processReport, which builds the option list in createFilteredOptionList, returns {reportOption: null} when getParticipantsAccountIDsForDisplay returns an empty list and the report is not a chat room. This is the source gate: the report never enters the option list at all.
  2. isValidReport, which re-checks every option in getValidOptions, has the same empty-participants exclusion.

I confirmed this with a failing test before fixing: an expense report with ownerAccountID set to the submitter and managerID set to the approver, but no participants map, returns zero results from getSearchOptions, while the identical report with the participants map populated is found. The first fix attempt only changed isValidReport and the test still failed, which proved the drop happens at the processReport source gate first.

Why this hits the approver/reimburser and not the other member: the approver's only link to the report is the workflow role (managerID), which never lands in participants. A member who has opened or interacted with the report holds a copy whose participants map is populated, so the same report passes the gate for them. The client must not treat an empty map as "no people" when the owner and manager are known. Note that the LHN visibility check (shouldReportBeInOptionList, used directly by SidebarUtils) has no participants check for expense reports, so the same report can stay visible in the LHN while search drops it, and opening the report works once found because canCurrentUserOpenReport counts managerID as a participant.

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

Give money request reports an owner/manager fallback for the "who are the people on this report" question, at both gates, through one shared helper. src/libs/OptionsListUtils/index.ts (+16 lines, one file changed):

  • New getReportOptionAccountIDs(report): returns the participants list as today when it is non-empty, and for money request reports with an empty list returns [ownerAccountID, managerID] (filtered to real numbers). Non-money-request reports are unchanged: with no participants and nothing to fall back to, they are still dropped.
  • processReport uses the helper instead of calling getParticipantsAccountIDsForDisplay directly, so the report enters the option list. As a side effect the option now carries the submitter/approver as its participants, so it renders with their names instead of falling back to the workspace name.
  • isValidReport uses the same helper, so the downstream re-check does not drop the report again.

Tests. New tests/unit/OptionsListUtilsExpenseReportWithoutParticipantsTest.tsx, 5 tests, all passing with the fix and 2 failing on baseline:

  • Expense report with a populated participants map is found (control, passes before and after).
  • Expense report with owner and manager but no participants map is found (fails on baseline, passes with the fix).
  • IOU report with owner and manager but no participants map is found (fails on baseline, passes with the fix).
  • A chat report with no participants and no people to fall back to is still dropped.
  • A money request report with no participants and no owner or manager is still dropped.

Related suites still green, run individually: OptionsListUtilsTest (370 tests), OptionsListUtilsSearchParityTest (7 tests), LhnSearchPreviewParityTest (162 tests). A single combined run of the three suites flaked at suite level on this machine and passed on individual re-runs; the two parity suites were also verified against baseline (the LHN parity suite fails to run on baseline too, a pre-existing environment flake).

What I could not verify. There was no access to the original report or the Slack thread with its screenshot, so the exact per-user sync state of the participants map could not be observed directly; the fix addresses the client-side gate that the failing test reproduces, and the per-user difference is consistent with the map being populated from report activity as delivered to each client. No real-device run of the Applause steps was possible here; manual QA worth doing before merge is: as a workspace approver, search for an expense report you approve but have never opened, and confirm it appears, then open it and confirm it loads. Lint and full typecheck could not run to green on the prep VM: lint-changed times out fetching origin/main and direct oxlint fails on the known environment breakage (the typescript-estree loader cannot load through the symlinked node_modules); the full typecheck was not attempted because this machine has repeatedly OOM-killed it. The targeted checks that could run are clean: cspell reports 0 issues on both changed files and esbuild parses both files. Lint and typecheck should be re-run on a machine with enough memory before the PR is opened.

What alternative solutions did you explore? (Optional)

  • Fix only isValidReport. Rejected by the probe: the report is dropped earlier, in processReport, so the downstream fix alone changes nothing.
  • Fix getParticipantsAccountIDsForDisplay itself to include owner/manager for money request reports. Rejected: that function feeds display names, avatars, and member lists across the app, so changing it would alter rendering far beyond search. The fallback belongs in the option-list layer, where the drop happens.
  • Fix the server-side Search page instead. Rejected: the Search page renders the server snapshot as-is, with no client-side access filtering besides the status filter, so a report the server returns would already show there. The dropped surface is local search (chat finder / SearchRouter autocomplete), which is client-side.
  • Have the server populate participants on money request reports. Rejected for this issue: that is a backend data-shape change outside this repo, while the client already knows the report's people from ownerAccountID and managerID.
  • MelvinBot's auto-proposal suggests investigating whether this is an access problem or a search-filtering problem, with no concrete change. This proposal implements the concrete change (owner/manager fallback at both option-list gates) with tests for it.

dankezo avatar Nov 21 '26 15:11 dankezo

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

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

Hi, Will check and update here once done

abdulrahuman5196 avatar Nov 24 '26 08:11 abdulrahuman5196

@abdulrahuman5196 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!