You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version Number: 9.4.15-3 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack:https://github.com/Expensify/Expensify/issues/557436 Email or phone of affected tester (no customers): - Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: Windows Windows 11 - Chrome
Action Performed:
As Admin, create a workspace.
Invite Submitter, Approver A, and Approver B.
Configure workflow: Approver A approves Submitter’s expenses.
As Submitter, submit an expense.
Log in as Approver A → observe that the needs approval filter is available in the Expense report section
As Admin, change workflow: now Approver B approves Submitter’s expenses.
Log in again as Approver A and check Expense report section
Expected Result:
Needs approval filter should remain visible in the Expense reports section, allowing them to filter and approve existing expenses.
Actual Result:
Needs approval filter disappears after approver change
The "Needs approval" filter is the APPROVE suggested search in the Expense reports section. Whether it is shown is decided purely from the current approval-workflow config, not from whether any reports are actually still waiting on the user.
getSuggestedSearchesVisibility computes the flag per policy as isApprovalEnabled && (isUserApprover || isSubmittedTo), where both isUserApprover and isSubmittedTo are derived from the policy's liveemployeeList / approver (SearchUIUtils.ts:1081-1096). isPolicyApprover only checks policy.approver and submitsTo/forwardsTo/overLimitForwardsTo on the current workflow (PolicyUtils.ts:606-614).
When the admin reroutes the submitter so Approver B becomes the approver, Approver A is instantly no longer in any policy's workflow → isUserApprover and isSubmittedTo both go false → shouldShowApproveSuggestion is false → the menu item is never pushed (SearchUIUtils.ts:4532-4540). This happens even though reports already routed to Approver A still carry them as managerID and remain pending their approval.
A report-data notion of approver (report.managerID === currentUserAccountID) already exists in ReportUtils, but it only drives per-report Approve/Pay buttons and "requires attention" — it is not consulted for this filter's visibility.
The APPROVE search query itself is correctly scoped to the user (to: [accountID]) and the tab even defines an emptyApproveResults empty state, so the design already expects the tab to render with zero current results — confirming the disappearance is a bug, not intended gating.
What changes do you think we should make in order to solve the problem?
Keep the APPROVE suggestion visible when the user still has reports awaiting their approval, in addition to the existing workflow-config check.
In getSuggestedSearchesVisibility / createTypeMenuSections (SearchUIUtils.ts:1045, :4481), additionally compute whether any expense report has the current user as managerID and is in a state that still requires their approval (open/processing, not yet approved/paid).
OR that signal into shouldShowApproveSuggestion (line 1110) so the tab stays for as long as there is pending work routed to the user, then naturally drops once those reports are approved/paid.
This matches the expected behavior: a former approver retains the filter only while reports are genuinely still waiting on them, and the existing to: [accountID] query already returns the correct set.
What alternative solutions did you explore? (Optional)
Show the tab whenever the user has ever been an approver in any approvals-enabled policy — simpler, but leaves the filter visible indefinitely with no pending work.
Backend keeps the user as a fallback approver after reassignment — out of scope for App and a larger workflow change.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/94021) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
Please re-state the problem that we are trying to solve in this issue.
When a workspace admin changes the approval workflow so that a different approver (Approver B) now handles a submitter's expenses, the previous approver (Approver A) loses the "Needs approval" filter/tab in the Expense reports section of Search. This happens even though reports that were already routed to Approver A before the change are still assigned to them (managerID still points to A) and still require their approval, leaving A with no way to filter to and act on those reports.
What is the root cause of that problem?
The "Needs approval" entry in the Expense reports section is rendered by createTypeMenuSections in SearchUIUtils.ts, which only pushes the APPROVE menu item when its visibility flag is true:
That visibility flag is produced by getSuggestedSearchesVisibility, where shouldShowApproveSuggestion is driven entirely by isPolicyEligibleForApproveSuggestion. The eligibility check is computed purely from the current policy workflow config — isUserApprover (isPolicyApprover) and isSubmittedTo (whether any employee's submitsTo/forwardsTo equals the current user):
When the admin reassigns the submitter from Approver A to Approver B, the policy's employeeList[submitter].submitsTo is rewritten to B and A is dropped from the policy's approver/forwardsTo entries. After that write, isPolicyApprover(policy, A) and isSubmittedTo both return false for A, so isEligibleForApproveSuggestion returns false and the APPROVE tab is removed. The gating signal is "is the user currently an approver in the workflow," not "does the user have reports currently awaiting their approval." Those diverge precisely in this scenario: the existing expense report keeps managerID = A (a workflow change does not retroactively reassign already-submitted reports), so A still has a real report to approve. This is exactly the report set the app already computes as reportsToApprove in the TODOS derived value via isApproveAction, which keys off report.managerID === currentUserAccountID — independent of the policy membership check that gates the tab.
What changes do you think we should make in order to solve the problem?
Keep the tab visible whenever the user still has reports awaiting their action, by OR-ing the already-computed TODO counts into the APPROVE/SUBMIT/PAY visibility inside createTypeMenuSections. The reportsToApprove count from ONYXKEYS.DERIVED.TODOS (todosReportCountsSelector) is already read by both SearchTypeMenuWide and SearchTypeMenuNarrow and passed down for the section badge, so it is available at the call site with no new Onyx plumbing — we just thread it into createTypeMenuSections (via TypeMenuSectionsParams) and use it as a fallback. The APPROVE push condition becomes:
This is safe and minimal: reportsToApprove is already gated by isApproveAction (current-manager, approval-enabled, non-held, processing report), so we only surface the tab when there is a concrete report the user can approve. It does not affect users who never had a report routed to them (count stays 0), and it does not change the badge or query logic. Applying the same fallback to SUBMIT and PAY closes the identical class of bug for "Drafts" and "Ready to pay" when reimburser/forwarding roles are reshuffled.
What alternative solutions did you explore? (Optional)
Broadening isPolicyApprover to also treat anyone listed as a report's managerID as an approver was rejected — getSuggestedSearchesVisibility only receives policies, not reports/transactions, so it cannot see managerID without adding new dependencies, and isPolicyApprover is a widely-used helper whose semantics ("is configured in the workflow") should not be overloaded with "has a stale assignment."
What specific scenarios should we cover in automated/manual tests to prevent this regression?
Unit-test createTypeMenuSections/getSuggestedSearchesVisibility for a user who is not an approver in the current workflow but has reportCounts[APPROVE] > 0, asserting the APPROVE menu item is present; and the inverse (no workflow role, zero count) asserting it is absent. Manual: reproduce the issue steps and confirm Approver A still sees "Needs approval" after the workflow is reassigned to Approver B while a previously-submitted report remains assigned to A, and that the tab disappears once A approves/that report leaves their queue.
Please re-state the problem that we are trying to solve in this issue.
The "Needs approval" suggested search (Approve filter) disappears from the Expense reports section for an approver after the admin reassigns the workflow approver to someone else, even though that approver still has reports actually pending their approval.
What is the root cause of that problem?
The visibility of the Approve suggested search is computed purely from the policy's current approval-workflow configuration, not from whether the user actually has reports awaiting their approval.
In getSuggestedSearchesVisibility, the Approve item is shown only when isPolicyEligibleForApproveSuggestion is true:
Both signals come from the static config: isUserApprover is isPolicyApprover(policy, currentUserEmail), which only checks policy.approver and the submitsTo/forwardsTo/overLimitForwardsTo fields of employeeList:
When the admin moves the approver from Approver A to Approver B, A is no longer referenced anywhere in the workflow config, so both isUserApprover and isSubmittedTo flip to false and suggestedSearchesVisibility[APPROVE] becomes false, removing the item here:
But changing the workflow does not retroactively reassign reports that were already submitted to A — those reports keep A as their current approver (managerID), so A still legitimately needs to approve them. The TODOS derived value already captures exactly these reports via isApproveAction (a per-report check based on the report's actual approver, not the config):
So reportsToApprove is non-empty for A, yet the filter that would let A act on them is hidden.
What changes do you think we should make in order to solve the problem?
We should keep the Approve suggestion visible whenever the user actually has at least one report awaiting their approval, by OR-ing the actual approve count into the config-based check.
useSearchTypeMenuSections already has the count available pattern (the same ONYXKEYS.DERIVED.TODOS selector is read in SearchTypeMenuWide). We read it in the hook and thread it through createTypeMenuSections into getSuggestedSearchesVisibility:
Then in getSuggestedSearchesVisibility, after computing isPolicyEligibleForApproveSuggestion, fold in the real count so the item survives a workflow change while reports are still pending:
Note: the approve count is per-user across policies, so we can fold it in once outside the per-policy loop rather than per policy. This reuses the already-derived reportsToApprove (no new data source) and naturally clears the filter once A approves or the reports leave their queue, since the TODOS count drops back to 0.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
Add a unit test for getSuggestedSearchesVisibility/createTypeMenuSections: given a user who is no longer an approver in the policy config (isPolicyApprover returns false and no submitsTo/forwardsTo references them) but who has reportsToApprove.length > 0, assert visibility[APPROVE] is true; and assert it is false when both the config check fails and the approve count is 0.
What alternative solutions did you explore? (Optional)
Instead of using the TODOS count, we could scan allReports directly inside getSuggestedSearchesVisibility for any expense report whose current approver is the user (e.g. via canApproveIOU, already imported in SearchUIUtils). This is more self-contained but re-derives data the TODOS config already computes, so reusing the existing count is cheaper and keeps a single source of truth for "reports awaiting my approval".
Please re-state the problem that we are trying to solve in this issue.
After an admin reassigns the approver (Approver A тЖТ Approver B), the "Needs approval" filter vanishes for Approver A in Expense reports тАФ even though reports submitted before the change are still routed to A and still await A's approval. A is left unable to filter or approve the in-flight reports they are still responsible for.
What is the root cause of that problem?
The "Needs approval" filter is shown based on the current workflow configuration, not on whether the user actually has anything to approve. Approver status is resolved by isPolicyApprover:
This reads the livepolicy.employeeList. When the admin reassigns approval to B, A no longer appears in anyone's submitsTo/forwardsTo chain, so isPolicyApprover(policy, A) becomes false and the filter is hidden.
But approvals already in flight are not retroactively reassigned тАФ the existing reports still have A as their manager/approver and are still in an awaiting-approval state. So the config says "A is not an approver" while the data says "A has reports to approve." The filter trusts the config (a prediction about future routing) instead of the data (what is actually pending now).
What changes do you think we should make in order to solve the problem?
Derive the filter's visibility from the data it filters, not from the workflow config. Show "Needs approval" exactly when there is at least one report currently awaiting this user's approval тАФ i.e. when the filter would actually return results:
- const canShowNeedsApprovalFilter = isPolicyApprover(policy, currentUserEmail);+ // Show the filter when the user actually has something to approve right now,+ // not when the *current* workflow config lists them as an approver. Approvals+ // already routed to a user survive a workflow reassignment, so visibility must+ // come from the reports, not from policy.employeeList.+ const canShowNeedsApprovalFilter = reports.some(+ (report) => report?.managerID === currentUserAccountID && isAwaitingApproval(report),+ );
isAwaitingApproval(report) is the same awaiting-approval predicate the filter itself uses (report is in the submitted/processing state and the current user is its manager). This makes filter visibility and filter results read from one source of truth, so the chip is shown precisely when it is actionable тАФ and hidden only once the user has genuinely cleared every report assigned to them.
Why this is the right direction:
Self-correcting. No reliance on the config staying consistent with in-flight approvals. The filter appears while there is work and disappears when there is none, regardless of how the workflow is edited afterward.
Covers the whole class. It also fixes forwarded / over-limit / multi-level approvals and any future routing change тАФ anything that leaves a report pending for a user now keeps that user's filter, because visibility is tied to the report, not the chain config.
No stale/illegal state. "A filter that returns rows but isn't shown" can't happen, because the same predicate decides both.
What alternative solutions did you explore?
Keep isPolicyApprover but also OR-in past approver assignments from the workflow history (rejected): requires tracking previous approvers and reconstructing old chains тАФ extra state that drifts, and still config-driven. The data already knows the truth (the report's managerID), so deriving from it is both simpler and complete.
Always show the filter for anyone who has ever been an approver (rejected): leaves a dead, always-empty filter for users with nothing pending. Tying visibility to actual pending reports keeps the UI honest.
Note: isPolicyApprover is verified against PolicyUtils. The filter call site identifiers (canShowNeedsApprovalFilter, the reports collection, and isAwaitingApproval) are illustrative of the existing config-based check тАФ please confirm the exact names/predicate at the "Needs approval" filter's visibility site before submitting.
changed the title [-]Spend - Needs approval filter disappears after approver change[/-][+][$250] Spend - Needs approval filter disappears after approver change[/+]on Jun 19, 2026
godzillaxbox19982014-lgtm commented on Jun 19, 2026
The local evidence matches this recurring failure shape: shared workspace list builds options without the same eligibility filter as another workspace surface. Here, src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx:222 and src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx:292 do not agree on the same expense report value, so the user-visible path can show a missing or stale state even though nearby data already has the needed context.
What changes do you think we should make in order to solve the problem?
Update src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx:222 to derive expense report from the workspace setup and policy state that owns this flow before the value is consumed.
Carry the same normalized value through src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx:292; that follows the safer family move to move the rule into the shared selector/helper, so the write/optimistic/read paths agree instead of only changing the visible component.
Keep the change inside the Workspace, Policy, Categories, Tags, Rules surface and avoid changing account/admin permission surfaces, policy owner/current-user exceptions.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
Add or update a regression in tests/unit/Policy*.ts for the exact issue flow: [$250] Spend - Needs approval filter disappears after approver change.
Cover the counter-case near src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx:222 so valid existing expense report behavior still works.
Manually repeat the issue steps after the patch and confirm the visible state/action is no longer stale.
What alternative solutions did you explore? (Optional)
I would not add a broad new condition outside these referenced paths; the safer fix is to keep expense report consistent at the first read/write boundary shown above.
The “Needs approval” item in the Search type menu is hidden by the menu visibility gate, not by the actual search query.
The Needs approval suggested search itself correctly searches for reports whose approve action targets the current user: action:approve plus to:<current accountID>. That query can still return already-submitted reports where the old approver remains the report manager.
But the menu decides whether to show the item from the current policy approval graph. It only sets shouldShowApproveSuggestion when the user is currently a policy approver or is currently referenced by submitsTo / forwardsTo in policy.employeeList: isSubmittedTo, isUserApprover, and shouldShowApproveSuggestion. After the admin changes the submitter’s approver from Approver A to Approver B, Approver A is no longer in that current workflow graph, so the menu condition at createTypeMenuSections removes the “Needs approval” item even though Approver A can still have existing reports to approve.
The app already has a derived source for existing approval todos: DERIVED.TODOS.reportsToApprove, which is populated from each report’s actual approve action eligibility and managerID, not just the current workflow membership: reportsToApprove.push(report).
What changes do you think we should make in order to solve the problem?
Keep the current policy-based visibility behavior, but also show the “Needs approval” search item whenever the current user has at least one existing report in DERIVED.TODOS.reportsToApprove.
Required changes:
Subscribe to ONYXKEYS.DERIVED.TODOS in useSearchTypeMenuSections with the existing todosReportCountsSelector.
Pass the approve count into createTypeMenuSections.
In createTypeMenuSections, compute shouldShowApproveSuggestion as:
current policy-based approve visibility, or
reportsToApproveCount > 0.
Use that combined boolean when pushing the APPROVE menu item.
Add a unit test covering the regression: current workflow no longer points to the old approver, but reportsToApproveCount is positive, so the approve item remains visible.
Tests to add/run:
Add a unit test in tests/unit/Search/SearchUIUtilsTest.ts for createTypeMenuSections.
Run npm test -- tests/unit/Search/SearchUIUtilsTest.ts.
Run npx eslint src/hooks/useSearchTypeMenuSections.ts src/libs/SearchUIUtils.ts tests/unit/Search/SearchUIUtilsTest.ts --max-warnings=0.
Run npm run typecheck-tsgo.
Run npm run react-compiler-compliance-check check-changed because a hook changes.
I considered making the “Needs approval” item always visible for any paid policy with approvals enabled, but that would expose the todo item to users who have neither current approver permissions nor existing reports to approve. I also considered changing the backend/search query, but the query already targets action:approve to:<current accountID> correctly; the bug is that the frontend hides the entry point before the user can run that query.
What alternative solutions did you explore? (Optional)
Activity
MelvinBot commentedon Jun 19, 2026
Proposal
What is the root cause of that problem?
The "Needs approval" filter is the
APPROVEsuggested search in the Expense reports section. Whether it is shown is decided purely from the current approval-workflow config, not from whether any reports are actually still waiting on the user.getSuggestedSearchesVisibilitycomputes the flag per policy asisApprovalEnabled && (isUserApprover || isSubmittedTo), where bothisUserApproverandisSubmittedToare derived from the policy's liveemployeeList/approver(SearchUIUtils.ts:1081-1096).isPolicyApproveronly checkspolicy.approverandsubmitsTo/forwardsTo/overLimitForwardsToon the current workflow (PolicyUtils.ts:606-614).When the admin reroutes the submitter so Approver B becomes the approver, Approver A is instantly no longer in any policy's workflow →
isUserApproverandisSubmittedToboth gofalse→shouldShowApproveSuggestionisfalse→ the menu item is never pushed (SearchUIUtils.ts:4532-4540). This happens even though reports already routed to Approver A still carry them asmanagerIDand remain pending their approval.Evidence & data flow
isEligibleForApproveSuggestion—SearchUIUtils.ts:1034-1037shouldShowApproveSuggestion:SearchUIUtils.ts:1110→ returned asvisibility[APPROVE]at:1152isPolicyApprover—PolicyUtils.ts:606-614report.managerID === currentUserAccountID) already exists inReportUtils, but it only drives per-report Approve/Pay buttons and "requires attention" — it is not consulted for this filter's visibility.APPROVEsearch query itself is correctly scoped to the user (to: [accountID]) and the tab even defines anemptyApproveResultsempty state, so the design already expects the tab to render with zero current results — confirming the disappearance is a bug, not intended gating.Flow: admin changes approver → Onyx
policy.employeeList/approverupdate →getSuggestedSearchesVisibilityrecomputes →isUserApprover=false,isSubmittedTo=false→visibility[APPROVE]=false→createTypeMenuSectionsomits the item.What changes do you think we should make in order to solve the problem?
Keep the
APPROVEsuggestion visible when the user still has reports awaiting their approval, in addition to the existing workflow-config check.getSuggestedSearchesVisibility/createTypeMenuSections(SearchUIUtils.ts:1045,:4481), additionally compute whether any expense report has the current user asmanagerIDand is in a state that still requires their approval (open/processing, not yet approved/paid).shouldShowApproveSuggestion(line1110) so the tab stays for as long as there is pending work routed to the user, then naturally drops once those reports are approved/paid.This matches the expected behavior: a former approver retains the filter only while reports are genuinely still waiting on them, and the existing
to: [accountID]query already returns the correct set.What alternative solutions did you explore? (Optional)
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/94021)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
MobileMage commentedon Jun 19, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a workspace admin changes the approval workflow so that a different approver (Approver B) now handles a submitter's expenses, the previous approver (Approver A) loses the "Needs approval" filter/tab in the Expense reports section of Search. This happens even though reports that were already routed to Approver A before the change are still assigned to them (
managerIDstill points to A) and still require their approval, leaving A with no way to filter to and act on those reports.What is the root cause of that problem?
The "Needs approval" entry in the Expense reports section is rendered by
createTypeMenuSectionsinSearchUIUtils.ts, which only pushes the APPROVE menu item when its visibility flag is true:App/src/libs/SearchUIUtils.ts
Lines 4532 to 4534 in 5b46d9a
That visibility flag is produced by
getSuggestedSearchesVisibility, whereshouldShowApproveSuggestionis driven entirely byisPolicyEligibleForApproveSuggestion. The eligibility check is computed purely from the current policy workflow config —isUserApprover(isPolicyApprover) andisSubmittedTo(whether any employee'ssubmitsTo/forwardsToequals the current user):App/src/libs/SearchUIUtils.ts
Lines 1034 to 1037 in 5b46d9a
When the admin reassigns the submitter from Approver A to Approver B, the policy's
employeeList[submitter].submitsTois rewritten to B and A is dropped from the policy'sapprover/forwardsToentries. After that write,isPolicyApprover(policy, A)andisSubmittedToboth returnfalsefor A, soisEligibleForApproveSuggestionreturnsfalseand the APPROVE tab is removed. The gating signal is "is the user currently an approver in the workflow," not "does the user have reports currently awaiting their approval." Those diverge precisely in this scenario: the existing expense report keepsmanagerID = A(a workflow change does not retroactively reassign already-submitted reports), so A still has a real report to approve. This is exactly the report set the app already computes asreportsToApprovein the TODOS derived value viaisApproveAction, which keys offreport.managerID === currentUserAccountID— independent of the policy membership check that gates the tab.What changes do you think we should make in order to solve the problem?
Keep the tab visible whenever the user still has reports awaiting their action, by OR-ing the already-computed TODO counts into the APPROVE/SUBMIT/PAY visibility inside
createTypeMenuSections. ThereportsToApprovecount fromONYXKEYS.DERIVED.TODOS(todosReportCountsSelector) is already read by bothSearchTypeMenuWideandSearchTypeMenuNarrowand passed down for the section badge, so it is available at the call site with no new Onyx plumbing — we just thread it intocreateTypeMenuSections(viaTypeMenuSectionsParams) and use it as a fallback. The APPROVE push condition becomes:This is safe and minimal:
reportsToApproveis already gated byisApproveAction(current-manager, approval-enabled, non-held, processing report), so we only surface the tab when there is a concrete report the user can approve. It does not affect users who never had a report routed to them (count stays 0), and it does not change the badge or query logic. Applying the same fallback to SUBMIT and PAY closes the identical class of bug for "Drafts" and "Ready to pay" when reimburser/forwarding roles are reshuffled.What alternative solutions did you explore? (Optional)
Broadening
isPolicyApproverto also treat anyone listed as a report'smanagerIDas an approver was rejected —getSuggestedSearchesVisibilityonly receivespolicies, not reports/transactions, so it cannot seemanagerIDwithout adding new dependencies, andisPolicyApproveris a widely-used helper whose semantics ("is configured in the workflow") should not be overloaded with "has a stale assignment."What specific scenarios should we cover in automated/manual tests to prevent this regression?
Unit-test
createTypeMenuSections/getSuggestedSearchesVisibilityfor a user who is not an approver in the current workflow but hasreportCounts[APPROVE] > 0, asserting the APPROVE menu item is present; and the inverse (no workflow role, zero count) asserting it is absent. Manual: reproduce the issue steps and confirm Approver A still sees "Needs approval" after the workflow is reassigned to Approver B while a previously-submitted report remains assigned to A, and that the tab disappears once A approves/that report leaves their queue.David-2002065 commentedon Jun 19, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
The "Needs approval" suggested search (Approve filter) disappears from the Expense reports section for an approver after the admin reassigns the workflow approver to someone else, even though that approver still has reports actually pending their approval.
What is the root cause of that problem?
The visibility of the Approve suggested search is computed purely from the policy's current approval-workflow configuration, not from whether the user actually has reports awaiting their approval.
In
getSuggestedSearchesVisibility, the Approve item is shown only whenisPolicyEligibleForApproveSuggestionis true:App/src/libs/SearchUIUtils.ts
Lines 1081 to 1096 in 7dbf6a5
which is driven by
isEligibleForApproveSuggestion→isApprover || isSubmittedToTarget:App/src/libs/SearchUIUtils.ts
Lines 1034 to 1037 in 7dbf6a5
Both signals come from the static config:
isUserApproverisisPolicyApprover(policy, currentUserEmail), which only checkspolicy.approverand thesubmitsTo/forwardsTo/overLimitForwardsTofields ofemployeeList:App/src/libs/PolicyUtils.ts
Lines 606 to 613 in 7dbf6a5
and
isSubmittedTosimilarly scanssubmitsTo/forwardsTo:App/src/libs/SearchUIUtils.ts
Lines 1081 to 1083 in 7dbf6a5
When the admin moves the approver from Approver A to Approver B, A is no longer referenced anywhere in the workflow config, so both
isUserApproverandisSubmittedToflip tofalseandsuggestedSearchesVisibility[APPROVE]becomesfalse, removing the item here:App/src/libs/SearchUIUtils.ts
Lines 4532 to 4540 in 7dbf6a5
But changing the workflow does not retroactively reassign reports that were already submitted to A — those reports keep A as their current approver (
managerID), so A still legitimately needs to approve them. The TODOS derived value already captures exactly these reports viaisApproveAction(a per-report check based on the report's actual approver, not the config):App/src/libs/actions/OnyxDerived/configs/todos.ts
Lines 65 to 67 in 7dbf6a5
So
reportsToApproveis non-empty for A, yet the filter that would let A act on them is hidden.What changes do you think we should make in order to solve the problem?
We should keep the Approve suggestion visible whenever the user actually has at least one report awaiting their approval, by OR-ing the actual approve count into the config-based check.
useSearchTypeMenuSectionsalready has the count available pattern (the sameONYXKEYS.DERIVED.TODOSselector is read inSearchTypeMenuWide). We read it in the hook and thread it throughcreateTypeMenuSectionsintogetSuggestedSearchesVisibility:Then in
getSuggestedSearchesVisibility, after computingisPolicyEligibleForApproveSuggestion, fold in the real count so the item survives a workflow change while reports are still pending:App/src/libs/SearchUIUtils.ts
Lines 1096 to 1110 in 7dbf6a5
Note: the approve count is per-user across policies, so we can fold it in once outside the per-policy loop rather than per policy. This reuses the already-derived
reportsToApprove(no new data source) and naturally clears the filter once A approves or the reports leave their queue, since the TODOS count drops back to 0.What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
Add a unit test for
getSuggestedSearchesVisibility/createTypeMenuSections: given a user who is no longer an approver in the policy config (isPolicyApproverreturnsfalseand nosubmitsTo/forwardsToreferences them) but who hasreportsToApprove.length > 0, assertvisibility[APPROVE]istrue; and assert it isfalsewhen both the config check fails and the approve count is0.What alternative solutions did you explore? (Optional)
Instead of using the TODOS count, we could scan
allReportsdirectly insidegetSuggestedSearchesVisibilityfor any expense report whose current approver is the user (e.g. viacanApproveIOU, already imported inSearchUIUtils). This is more self-contained but re-derives data the TODOS config already computes, so reusing the existing count is cheaper and keeps a single source of truth for "reports awaiting my approval".dostonbunyodov0006 commentedon Jun 19, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
After an admin reassigns the approver (Approver A тЖТ Approver B), the "Needs approval" filter vanishes for Approver A in Expense reports тАФ even though reports submitted before the change are still routed to A and still await A's approval. A is left unable to filter or approve the in-flight reports they are still responsible for.
What is the root cause of that problem?
The "Needs approval" filter is shown based on the current workflow configuration, not on whether the user actually has anything to approve. Approver status is resolved by
isPolicyApprover:This reads the live
policy.employeeList. When the admin reassigns approval to B, A no longer appears in anyone'ssubmitsTo/forwardsTochain, soisPolicyApprover(policy, A)becomesfalseand the filter is hidden.But approvals already in flight are not retroactively reassigned тАФ the existing reports still have A as their manager/approver and are still in an awaiting-approval state. So the config says "A is not an approver" while the data says "A has reports to approve." The filter trusts the config (a prediction about future routing) instead of the data (what is actually pending now).
What changes do you think we should make in order to solve the problem?
Derive the filter's visibility from the data it filters, not from the workflow config. Show "Needs approval" exactly when there is at least one report currently awaiting this user's approval тАФ i.e. when the filter would actually return results:
isAwaitingApproval(report)is the same awaiting-approval predicate the filter itself uses (report is in the submitted/processing state and the current user is its manager). This makes filter visibility and filter results read from one source of truth, so the chip is shown precisely when it is actionable тАФ and hidden only once the user has genuinely cleared every report assigned to them.Why this is the right direction:
What alternative solutions did you explore?
Keep
isPolicyApproverbut also OR-in past approver assignments from the workflow history (rejected): requires tracking previous approvers and reconstructing old chains тАФ extra state that drifts, and still config-driven. The data already knows the truth (the report'smanagerID), so deriving from it is both simpler and complete.Always show the filter for anyone who has ever been an approver (rejected): leaves a dead, always-empty filter for users with nothing pending. Tying visibility to actual pending reports keeps the UI honest.
Note:
isPolicyApproveris verified againstPolicyUtils. The filter call site identifiers (canShowNeedsApprovalFilter, the reports collection, andisAwaitingApproval) are illustrative of the existing config-based check тАФ please confirm the exact names/predicate at the "Needs approval" filter's visibility site before submitting.melvin-bot commentedon Jun 19, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @rojiphil (
External)melvin-bot commentedon Jun 19, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022067914058094347586
[-]Spend - Needs approval filter disappears after approver change[/-][+][$250] Spend - Needs approval filter disappears after approver change[/+]godzillaxbox19982014-lgtm commentedon Jun 19, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
[$250] Spend - Needs approval filter disappears after approver change
What is the root cause of that problem?
I traced this to the path that handles
expense report:includes):(!policy?.preventSelfApproval || !approversEmail?.includes(member.login)) &&confirmedMembers):const confirmedMembers = stagedMembers.filter((m) => !!policy?.employeeList?.[normalizeLogin(m.email)]);existingApproverEmail):const existingApproverEmail = newMember?.login ? membersInExistingWorkflows.get(newMember.login) : undefined;src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx:222andsrc/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx:292do not agree on the sameexpense reportvalue, so the user-visible path can show a missing or stale state even though nearby data already has the needed context.What changes do you think we should make in order to solve the problem?
src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx:222to deriveexpense reportfrom the workspace setup and policy state that owns this flow before the value is consumed.src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx:292; that follows the safer family move to move the rule into the shared selector/helper, so the write/optimistic/read paths agree instead of only changing the visible component.What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
tests/unit/Policy*.tsfor the exact issue flow: [$250] Spend - Needs approval filter disappears after approver change.src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx:222so valid existingexpense reportbehavior still works.What alternative solutions did you explore? (Optional)
expense reportconsistent at the first read/write boundary shown above.x-dev90 commentedon Jun 19, 2026
Proposal
What is the root cause of that problem?
The “Needs approval” item in the Search type menu is hidden by the menu visibility gate, not by the actual search query.
The
Needs approvalsuggested search itself correctly searches for reports whose approve action targets the current user:action:approveplusto:<current accountID>. That query can still return already-submitted reports where the old approver remains the report manager.But the menu decides whether to show the item from the current policy approval graph. It only sets
shouldShowApproveSuggestionwhen the user is currently a policy approver or is currently referenced bysubmitsTo/forwardsToinpolicy.employeeList:isSubmittedTo,isUserApprover, andshouldShowApproveSuggestion. After the admin changes the submitter’s approver from Approver A to Approver B, Approver A is no longer in that current workflow graph, so the menu condition atcreateTypeMenuSectionsremoves the “Needs approval” item even though Approver A can still have existing reports to approve.The app already has a derived source for existing approval todos:
DERIVED.TODOS.reportsToApprove, which is populated from each report’s actual approve action eligibility andmanagerID, not just the current workflow membership:reportsToApprove.push(report).What changes do you think we should make in order to solve the problem?
Keep the current policy-based visibility behavior, but also show the “Needs approval” search item whenever the current user has at least one existing report in
DERIVED.TODOS.reportsToApprove.Required changes:
ONYXKEYS.DERIVED.TODOSinuseSearchTypeMenuSectionswith the existingtodosReportCountsSelector.createTypeMenuSections.createTypeMenuSections, computeshouldShowApproveSuggestionas:reportsToApproveCount > 0.APPROVEmenu item.reportsToApproveCountis positive, so the approve item remains visible.Tests to add/run:
tests/unit/Search/SearchUIUtilsTest.tsforcreateTypeMenuSections.npm test -- tests/unit/Search/SearchUIUtilsTest.ts.npx eslint src/hooks/useSearchTypeMenuSections.ts src/libs/SearchUIUtils.ts tests/unit/Search/SearchUIUtilsTest.ts --max-warnings=0.npm run typecheck-tsgo.npm run react-compiler-compliance-check check-changedbecause a hook changes.I considered making the “Needs approval” item always visible for any paid policy with approvals enabled, but that would expose the todo item to users who have neither current approver permissions nor existing reports to approve. I also considered changing the backend/search query, but the query already targets
action:approve to:<current accountID>correctly; the bug is that the frontend hides the entry point before the user can run that query.What alternative solutions did you explore? (Optional)
Fixed Demo:
Screencast.From.2026-06-20.13-38-50.mp4
66 remaining items
melvin-bot commentedon Aug 5, 2026
@rojiphil 12 days overdue now... This issue's end is nigh!
melvin-bot commentedon Aug 7, 2026
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
mvtglobally commentedon Aug 8, 2026
Issue not reproducible during KI retests. (First week)
melvin-bot commentedon Aug 10, 2026
This issue has not been updated in over 14 days. @rojiphil eroding to Weekly issue.
melvin-bot commentedon Aug 14, 2026
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
melvin-bot commentedon Aug 21, 2026
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
mvtglobally commentedon Aug 22, 2026
Issue not reproducible during KI retests. (Second week)
rojiphil commentedon Aug 27, 2026
Requested in slack here to close this issue as it is no longer reproducible.