Skip to content

[WIP] feat: expose Accounting suggested searches to Auditors#89513

Open
KJ21-ENG wants to merge 2 commits intoExpensify:mainfrom
KJ21-ENG:fix/89173-auditor-accounting-saved-searches
Open

[WIP] feat: expose Accounting suggested searches to Auditors#89513
KJ21-ENG wants to merge 2 commits intoExpensify:mainfrom
KJ21-ENG:fix/89173-auditor-accounting-saved-searches

Conversation

@KJ21-ENG
Copy link
Copy Markdown
Contributor

@KJ21-ENG KJ21-ENG commented May 4, 2026

Explanation of Change

Visibility of the Accounting section's suggested searches in the Search left navigation is computed in getSuggestedSearchesVisibility in src/libs/SearchUIUtils.ts. Four of the section's eligibility flags were gated strictly on isAdmin:

  • isEligibleForUnapprovedCashSuggestion (Unapproved cash)
  • isEligibleForUnapprovedCardSuggestion (Unapproved card)
  • isEligibleForExpensifyCardSuggestion (Reconciliation — Expensify Card branch)
  • isEligibleForReimbursementsSuggestion (Reconciliation — Reimbursements branch)

RECONCILIATION itself is the OR of the latter two, so it was admin-only as well. isAuditor was already computed in the same loop and used for isEligibleForTopSpendersSuggestion, but it was never extended to the Accounting-section flags. As a result, members with the read-only Auditor role — who already have visibility into every report on the workspace — saw an empty/missing Accounting section even though hiding the shortcuts gave them no security benefit (they can manually search for the same reports).

This PR hoists the existing isAuditor declaration to sit beside isAdmin and replaces isAdmin with (isAdmin || isAuditor) in the four Accounting-section eligibility expressions, matching the pattern already used for Top spenders a few lines below. EXPORT and STATEMENTS eligibility are intentionally not modified — they are not admin-gated today and behave the same for Auditors as for any non-exporter member.

No backend, API, or Onyx-key changes are required.

Fixed Issues

$ #89173
PROPOSAL: #89173 (comment)

Tests

Pre-requisites: a paid (Collect / Control / Track for Teams) workspace with Approvals on (Basic or Advanced), Payments on, and Expensify Cards enabled. Two test accounts where Account A is Owner/Admin and Account B will be flipped to Auditor.

  1. As Account A on https://dev.new.expensify.com:8082, open Spend and confirm the Accounting section in the left rail shows at least Cash accruals and Bank reconciliation.
  2. As Account A, open the workspace's Members page and change Account B's role to Auditor.
  3. In a separate browser context (private window or second profile), log in as Account B on https://dev.new.expensify.com:8082 and hard-refresh.
  4. Open Spend and confirm the Accounting section now shows the items it shows for Account A — at minimum Bank reconciliation (and Unapproved cash / Unapproved card if the workspace meets their preconditions).
  5. Confirm Insights → Top spenders still appears for the Auditor (regression check — was already permitted for Auditors before this PR).
  6. Change Account B's role to plain User, hard-refresh, confirm the Accounting section becomes empty (regression check — fix only adds Auditor, not arbitrary roles).
  7. Change Account B back to Admin, hard-refresh, confirm the Accounting section is unchanged from step 1 (regression check — Admin behaviour unaffected).
  8. On the same workspace, turn Approvals off temporarily as Account A. Hard-refresh as the Auditor and confirm Unapproved cash and Unapproved card disappear (regression check — prerequisite gates still hold). Turn Approvals back on.
  9. Verify that no errors appear in the JS console.
  • Verify that no errors appear in the JS console

Offline tests

  1. Complete steps 1–4 of the Tests section to confirm the fix works online.
  2. Disconnect the network on the Auditor's browser (DevTools → Network → Offline).
  3. Open Spend and confirm the Accounting section continues to render the same items as in step 4. The visibility logic operates on locally-cached Onyx policy data, so no network round-trip is required.
  4. Reconnect the network and confirm no items are added or removed when policies finish refreshing.

QA Steps

Same prerequisites as Tests. Reproduce on staging.new.expensify.com once this is merged and deployed.

  1. As an Owner/Admin of a paid workspace with Approvals on, Payments on, and Expensify Cards enabled, open Spend and verify the Accounting section in the left rail lists Cash accruals and Bank reconciliation (and any other items the workspace's specific configuration enables).
  2. Demote a second member of the same workspace to Auditor.
  3. Log in as that Auditor on a separate browser context and open Spend. Verify the Accounting section now lists the same role-gated items the Owner sees on this workspace (specifically Bank reconciliation, plus Unapproved cash / Unapproved card when their preconditions are met).
  4. Verify Insights → Top spenders is still visible for the Auditor (no regression).
  5. Change the same member's role to plain User and verify the Accounting section becomes empty for them.
  6. As an Admin, verify the Accounting section is unchanged from before this PR.
  7. Verify that no errors appear in the JS console.
  • 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

Verified on macOS Safari (staging — bug present) and macOS Chrome (dev server with this PR's fix — Auditor now sees Bank reconciliation in the Accounting section). Drag-and-drop the before/after screenshots here.

@KJ21-ENG KJ21-ENG requested review from a team as code owners May 4, 2026 14:26
@melvin-bot melvin-bot Bot requested a review from mananjadhav May 4, 2026 14:26
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented May 4, 2026

@mananjadhav 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 JmillsExpensify and removed request for a team May 4, 2026 14:26
Update getSuggestedSearchesVisibility in src/libs/SearchUIUtils.ts to
treat the workspace Auditor role the same as Admin for the four
Accounting-section eligibility flags (Unapproved cash, Unapproved card,
Expensify Card, Reimbursements). Auditors already have read access to
all reports on the workspace, so hiding the Accounting suggested-search
shortcuts from them was inconsistent. The change mirrors the existing
isAuditor handling on the Top Spenders flag a few lines below.

Fixes Expensify#89173
@KJ21-ENG KJ21-ENG force-pushed the fix/89173-auditor-accounting-saved-searches branch from 7571f1a to fdc1b73 Compare May 4, 2026 14:53
Cover the new (isAdmin || isAuditor) branch in
getSuggestedSearchesVisibility for:
- unapprovedCash (Auditor passes, User does not)
- unapprovedCard (Auditor passes, User does not)
- reconciliation (Auditor passes via Expensify-Card branch)

Plus regression checks that User stays excluded and Admin
behaviour is unchanged.
@KJ21-ENG KJ21-ENG changed the title Expose Accounting suggested searches to Auditors [WIP] feat: expose Accounting suggested searches to Auditors May 4, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/libs/SearchUIUtils.ts 63.81% <100.00%> (ø)
... and 44 files with indirect coverage changes

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.

1 participant