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
{{ message }}
Repository navigation
[Awaiting checklist completion] Approver - The expense approver can be deleted, a warning doesn't appear. #81658
Version Number: v9.3.13-1 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack:#79891 Email or phone of affected tester (no customers): n/a Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: Mac 15.4.1 Safari App Component: Workspace Settings
Create a workspace
3.Add another member to a workspace.
4.Create a new report with an expense and submit it.
5.In that report select 'change the approver' and add the new member as an approver.
6.Go to workspace members and try to remove that member.
Expected Result:
Approver can't be deleted, a warning message appears under the approvers field,
The red dot appears near the Workspace and Members tabs
Actual Result:
Approver is deleted, the warning doesn't appear, but there is a red dot near the Workspace, and the Members tab
🚨 Edited by proposal-police: This proposal was edited at 2026-02-06 11:26:40 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Approver is deleted, the warning doesn't appear, but there is a red dot near the Workspace, and the Members tab
What is the root cause of that problem?
The isApprover function in src/libs/actions/Policy/Member.ts only checks policy-level approvers (policy.approver, employee.submitsTo, employee.forwardsTo, employee.overLimitForwardsTo), but it does NOT check report-level approvers. When a user uses "Change the approver" on a submitted report, the addReportApprover function sets report.managerID to the new approver's account ID. This is a report-level assignment that is not reflected in the policy's employeeList fields. As a result, when trying to remove that member, isApprover returns false, no warning is shown, and the member is optimistically removed. The backend then detects the conflict and returns an error (red dot), but the frontend has already processed the removal.
What changes do you think we should make in order to solve the problem?
For the the warning doesn't appear bug we should extend the isApprover function to also check if the member is set as managerID on any submitted expense report in the workspace.
function isApprover(policy: OnyxEntry<Policy>, employeeLogin: string) {
if (policy?.approver === employeeLogin) {
return true;
}
- return Object.values(policy?.employeeList ?? {}).some(+ if (Object.values(policy?.employeeList ?? {}).some(
(employee) => employee?.submitsTo === employeeLogin || employee?.forwardsTo === employeeLogin || employee?.overLimitForwardsTo === employeeLogin,
- );+ )) {+ return true;+ }++ // Check if the member is a report-level approver (set via "Change the approver")+ const memberAccountID = PersonalDetailsUtils.getAccountIDsByLogins([employeeLogin]).at(0);+ if (memberAccountID) {+ const workspaceReports = ReportUtils.getAllWorkspaceReports(policy?.id);+ if (workspaceReports.some(+ (report) => report?.managerID === memberAccountID && report?.statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED,+ )) {+ return true;+ }+ }++ return false;
}
What alternative solutions did you explore? (Optional)
N/A
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
🚨 Edited by proposal-police: This proposal was edited at 2026-02-06 10:14:37 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Approver users, either workspace-level approvers or report-level managers, can be removed even when the UI does not reliably show the approver warning, so the DELETE API is called and approval workflows become inconsistent.
What is the root cause of that problem?
In this implementation, the earliest incorrect assumption is that caller components will always detect approvers and block deletion before calling the shared deletion action. In src/libs/actions/Policy/Member.ts, the removeMembers function performs deletions unconditionally and does not check for report-level manager assignments, so it can issue the DELETE even when a selected member is an approver.
What changes do you think we should make in order to solve the problem?
State the single invariant you’re enforcing
"The shared policy member deletion action will never call the delete API when any selected member is an approver (workspace-level or report-level); instead it will set a per-login Onyx error on those approvers."
Point to the earliest incorrect assumption
Earliest incorrect assumption: callers will detect approvers and block deletion prior to calling removeMembers.
Evidence: removeMembers constructs optimistic, success, and failure Onyx payloads and calls API.write(WRITE_COMMANDS.DELETE_MEMBERS_FROM_WORKSPACE, ...) unconditionally as the first client-side mutation.
Apply the smallest shared-layer fix
Where: src/libs/actions/Policy/Member.ts, function removeMembers(...).
What: Insert a short guard at the top of removeMembers that uses the function policyID if present, builds a deduplicated set of approvers, detects report-level managers on submitted reports, and blocks deletion by merging per-login errors into Onyx instead of calling the API.
Why this layer
removeMembers is the single shared owner of deletion. Centralizing the check removes duplication and race windows across callers.
The exact code and scope
Files changed: src/libs/actions/Policy/Member.ts
Function modified: removeMembers(policy: OnyxEntry, selectedMemberEmails: string[], policyMemberEmailsToAccountIDs: Record<string, number>)
Scope size: One file, single guard insertion of about 25 to 40 lines, no new modules and no signature changes.
Exact code to insert, immediately after the function early-return and before any optimistic or API.write logic:
// File: src/libs/actions/Policy/Member.ts// --- START: Block approver deletions at shared action layer ---// Mixed selections (approver + non-approver) intentionally block the entire deletion;// callers must update workflows/approvers and retry.constresolvedPolicyID=typeofpolicyID!=='undefined' ? policyID : (policy?.id??policy?.policyID);// Build deduped set of workspace approversconstapproverLoginsSet=newSet(selectedMemberEmails.filter((login)=>isApprover(policy,login)));// Short-circuit: if not all selected are already workspace approvers and we have a policyID, check report-level managersif(resolvedPolicyID&&approverLoginsSet.size<selectedMemberEmails.length){constworkspaceReports=ReportUtils.getAllWorkspaceReports(resolvedPolicyID)||[];for(constloginofselectedMemberEmails){if(approverLoginsSet.has(login)){continue;}constaccountID=policyMemberEmailsToAccountIDs[login];if(!accountID){// Gracefully skip unmapped loginscontinue;}constisReportApprover=workspaceReports.some((report)=>Number(report?.managerID)===Number(accountID)&&Number(report?.statusNum)===Number(CONST.REPORT.STATUS_NUM.SUBMITTED),);if(isReportApprover){approverLoginsSet.add(login);}}}if(approverLoginsSet.size>0){// Ensure we have a valid policyID before merging to Onyx (avoid POLICYundefined)if(!resolvedPolicyID){return;}constpolicyKey=`${ONYXKEYS.COLLECTION.POLICY}${resolvedPolicyID}`asconst;constemployeeErrors: Record<string,{errors: Record<string,string>|null}>={};for(constloginofArray.from(approverLoginsSet)){employeeErrors[login]={errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.people.error.genericRemove'),};}// Merge only per-login errors to avoid clobbering other employeeList entriesOnyx.merge(policyKey,{employeeList: employeeErrors,});// Block deletion — callers must update approval workflows / approvers and retry.return;}// --- END: Block approver deletions at shared action layer ---
What alternative solutions did you explore? (Optional)
Caller-side blocking and backend enforcement were considered, but both are weaker or higher scope compared to a single shared-layer guard.
Please re-state the problem that we are trying to solve in this issue.
When a workspace member is assigned as an approver on a specific expense report via the "Change Approver" feature, attempting to remove them from the workspace does not show the expected warning dialog. The removal proceeds and then fails with a backend error (red dot), even though the member should be protected from removal.
What is the root cause of that problem?
The root cause is that the isApprover() function in src/libs/actions/Policy/Member.ts only checks for policy-level approver assignments and does not account for report-level approvers created through the "Change Approver" feature.
It checks policy.approver (the default workspace approver) and the submitsTo, forwardsTo, and overLimitForwardsTo fields in the policy's employeeList. These fields represent workspace-level approval workflows.
This creates a report-level approver relationship that exists only in report.managerID and is NOT reflected in the policy's employeeList fields. Because isApprover() doesn't check for report-level approvers, it returns false for these members.
The isApprover() function is called before attempting member removal in both the bulk removal flow and individual member removal flow:
Since isApprover() returns false, the warning dialog is not shown, the removal proceeds to the API, and the backend correctly rejects it (because the backend knows this member is an active approver), resulting in a red dot error.
What changes do you think we should make in order to solve the problem?
We should extend the isApprover() function in src/libs/actions/Policy/Member.ts to also check if the employee is a managerID on any active expense report in the workspace:
This ensures that members who are report-level approvers (via report.managerID) are properly detected and protected from removal, triggering the appropriate warning dialog.
What alternative solutions did you explore?
Instead of modifying isApprover(), we could add a separate isReportLevelApprover() check at each call site in WorkspaceMembersPage.tsx and WorkspaceMemberDetailsPage.tsx. However, this approach would require changes in multiple locations and could miss future call sites. Fixing isApprover() centrally ensures all existing and future uses of this function benefit from the complete approver check.
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal Template
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
@twisterdotcom confirming whether you checked the regression test proposal and created a QA GH?
update: doesn't seem like it, so i'll go ahead and do that
seems like the dropdown toggle is what caused confusion - feel free to remove the markup in the BugZero template so that it's easier to check moving forward!
Activity
melvin-bot commentedon Feb 6, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @QichenZhu (
External)melvin-bot commentedon Feb 6, 2026
Triggered auto assignment to @twisterdotcom (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.daledah commentedon Feb 6, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-02-06 11:26:40 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Approver is deleted, the warning doesn't appear, but there is a red dot near the Workspace, and the Members tab
What is the root cause of that problem?
The
isApproverfunction insrc/libs/actions/Policy/Member.tsonly checks policy-level approvers (policy.approver,employee.submitsTo,employee.forwardsTo,employee.overLimitForwardsTo), but it does NOT check report-level approvers. When a user uses "Change the approver" on a submitted report, theaddReportApproverfunction setsreport.managerIDto the new approver's account ID. This is a report-level assignment that is not reflected in the policy'semployeeListfields. As a result, when trying to remove that member,isApproverreturnsfalse, no warning is shown, and the member is optimistically removed. The backend then detects the conflict and returns an error (red dot), but the frontend has already processed the removal.App/src/libs/actions/Policy/Member.ts
Lines 78 to 85 in dedd11d
App/src/libs/actions/IOU/index.ts
Lines 13401 to 13460 in dedd11d
What changes do you think we should make in order to solve the problem?
the warning doesn't appearbug we should extend theisApproverfunction to also check if the member is set asmanagerIDon any submitted expense report in the workspace.function isApprover(policy: OnyxEntry<Policy>, employeeLogin: string) { if (policy?.approver === employeeLogin) { return true; } - return Object.values(policy?.employeeList ?? {}).some( + if (Object.values(policy?.employeeList ?? {}).some( (employee) => employee?.submitsTo === employeeLogin || employee?.forwardsTo === employeeLogin || employee?.overLimitForwardsTo === employeeLogin, - ); + )) { + return true; + } + + // Check if the member is a report-level approver (set via "Change the approver") + const memberAccountID = PersonalDetailsUtils.getAccountIDsByLogins([employeeLogin]).at(0); + if (memberAccountID) { + const workspaceReports = ReportUtils.getAllWorkspaceReports(policy?.id); + if (workspaceReports.some( + (report) => report?.managerID === memberAccountID && report?.statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED, + )) { + return true; + } + } + + return false; }What alternative solutions did you explore? (Optional)
N/A
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
twinkle-react commentedon Feb 6, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-02-06 10:14:37 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Approver users, either workspace-level approvers or report-level managers, can be removed even when the UI does not reliably show the approver warning, so the DELETE API is called and approval workflows become inconsistent.
What is the root cause of that problem?
In this implementation, the earliest incorrect assumption is that caller components will always detect approvers and block deletion before calling the shared deletion action. In src/libs/actions/Policy/Member.ts, the removeMembers function performs deletions unconditionally and does not check for report-level manager assignments, so it can issue the DELETE even when a selected member is an approver.
What changes do you think we should make in order to solve the problem?
State the single invariant you’re enforcing
"The shared policy member deletion action will never call the delete API when any selected member is an approver (workspace-level or report-level); instead it will set a per-login Onyx error on those approvers."
Point to the earliest incorrect assumption
Earliest incorrect assumption: callers will detect approvers and block deletion prior to calling removeMembers.
Evidence: removeMembers constructs optimistic, success, and failure Onyx payloads and calls API.write(WRITE_COMMANDS.DELETE_MEMBERS_FROM_WORKSPACE, ...) unconditionally as the first client-side mutation.
Apply the smallest shared-layer fix
Where: src/libs/actions/Policy/Member.ts, function removeMembers(...).
What: Insert a short guard at the top of removeMembers that uses the function policyID if present, builds a deduplicated set of approvers, detects report-level managers on submitted reports, and blocks deletion by merging per-login errors into Onyx instead of calling the API.
Why this layer
removeMembers is the single shared owner of deletion. Centralizing the check removes duplication and race windows across callers.
The exact code and scope
Files changed: src/libs/actions/Policy/Member.ts
Function modified: removeMembers(policy: OnyxEntry, selectedMemberEmails: string[], policyMemberEmailsToAccountIDs: Record<string, number>)
Scope size: One file, single guard insertion of about 25 to 40 lines, no new modules and no signature changes.
Exact code to insert, immediately after the function early-return and before any optimistic or API.write logic:
What alternative solutions did you explore? (Optional)
Caller-side blocking and backend enforcement were considered, but both are weaker or higher scope compared to a single shared-layer guard.
QichenZhu commentedon Feb 6, 2026
This wasn't an issue earlier this week. See the screenshots I took then vs. yesterday. The offending commit is likely within the regression period.
twilight2294 commentedon Feb 6, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a workspace member is assigned as an approver on a specific expense report via the "Change Approver" feature, attempting to remove them from the workspace does not show the expected warning dialog. The removal proceeds and then fails with a backend error (red dot), even though the member should be protected from removal.
What is the root cause of that problem?
The root cause is that the
isApprover()function insrc/libs/actions/Policy/Member.tsonly checks for policy-level approver assignments and does not account for report-level approvers created through the "Change Approver" feature.The
isApprover()function currently checks three policy-level fields:https://github.com/Expensify/App/blob/main/src/libs/actions/Policy/Member.ts#L78-L85
It checks
policy.approver(the default workspace approver) and thesubmitsTo,forwardsTo, andoverLimitForwardsTofields in the policy'semployeeList. These fields represent workspace-level approval workflows.However, when a user uses the "Change Approver" feature on a submitted report (via
ReportChangeApproverPage→ReportAddApproverPage), it calls theaddReportApprover()function which only updates themanagerIDfield on that specific report:https://github.com/Expensify/App/blob/main/src/libs/actions/IOU/index.ts#L13401
This creates a report-level approver relationship that exists only in
report.managerIDand is NOT reflected in the policy'semployeeListfields. BecauseisApprover()doesn't check for report-level approvers, it returnsfalsefor these members.The
isApprover()function is called before attempting member removal in both the bulk removal flow and individual member removal flow:Since
isApprover()returnsfalse, the warning dialog is not shown, the removal proceeds to the API, and the backend correctly rejects it (because the backend knows this member is an active approver), resulting in a red dot error.What changes do you think we should make in order to solve the problem?
We should extend the
isApprover()function insrc/libs/actions/Policy/Member.tsto also check if the employee is amanagerIDon any active expense report in the workspace:https://github.com/Expensify/App/blob/main/src/libs/actions/Policy/Member.ts#L78-L85
This ensures that members who are report-level approvers (via
report.managerID) are properly detected and protected from removal, triggering the appropriate warning dialog.What alternative solutions did you explore?
Instead of modifying
isApprover(), we could add a separateisReportLevelApprover()check at each call site inWorkspaceMembersPage.tsxandWorkspaceMemberDetailsPage.tsx. However, this approach would require changes in multiple locations and could miss future call sites. FixingisApprover()centrally ensures all existing and future uses of this function benefit from the complete approver check.QichenZhu commentedon Feb 7, 2026
@twisterdotcom, PR #80071 appears to be the cause. Could you assign @nkdengineer and @dukenv0307? Thanks!
cc @jasperhuangg @brianlee-expensify
daledah commentedon Feb 7, 2026
@QichenZhu There are two issues in this issue:
And the PR link you provided above only relates to the second bug. Since this issue was external, could you please check the proposals?
24 remaining items
dukenv0307 commentedon Feb 23, 2026
@twisterdotcom We don't need payment for this issue since it's our regression
twisterdotcom commentedon Feb 23, 2026
Okay, can we close now then?
brianlee-expensify commentedon Feb 23, 2026
@twisterdotcom correct, i'll close this one out, as i will add the payment summary on this GH (decrease by 50% from $250 to $125)
brianlee-expensify commentedon Feb 23, 2026
@twisterdotcom actually, reopening this so that @dukenv0307 can fill out the BZ checklist (if needed)
feel free to close out accordingly
dukenv0307 commentedon Feb 24, 2026
BugZero Checklist:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: https://github.com/Expensify/App/pull/80071/changes#r2844373837
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue: https://github.com/Expensify/Expensify/issues/603825
Regression Test Proposal
Precondition:
Test:
Do we agree 👍 or 👎
dukenv0307 commentedon Feb 24, 2026
@brianlee-expensify I completed
brianlee-expensify commentedon Feb 24, 2026
@twisterdotcom confirming whether you checked the regression test proposal and created a QA GH?
update: doesn't seem like it, so i'll go ahead and do that
seems like the dropdown toggle is what caused confusion - feel free to remove the markup in the BugZero template so that it's easier to check moving forward!
twisterdotcom commentedon Feb 24, 2026
Nice, thank you.