Repository navigation
Skip members pending deletion when building approval workflows - #99988
Conversation
A member removed while offline keeps a stale submitsTo, which built an extra approval workflow with no members and marked their old approver as used. Skip pending-DELETE members in both the employeeList and rules based conversions. Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
Web: partial pass — 8 of 9 steps verified, including the key regression check. Removing the pending-deletion default approver while offline correctly falls back to the Admin with no phantom workflow row, and setting Employee 2 as approver persists unchanged after going back online. Step 7 could not be run: this Collect-plan workspace paywalls every route to a second approver picker behind a Control-plan upgrade.
Step 6 is the regression this PR fixes, and it passed. Step 7 (the Evidence (9)Workspace with Employee 1 set as default approver (precondition)
Force offline toggle enabled, offline banner visible
Employee 1 shown strikethrough as pending removal while offline
Approver automatically switched to Admin, single workflow row
Approver detail screen opened from Edit approval workflow
Default workflow shows Employee 2 as approver with no phantom duplicate row (key regression check)
Force offline toggled back off, no offline banner
Workflows list unchanged after returning online
Add approval workflow blocked by Control-plan upgrade paywall
|
|
@MelvinBot pull main and fix conflict |
…lWorkflowOnDeletedMember # Conflicts: # src/libs/WorkflowUtils.ts
|
Merged The conflict: one hunk in Resolution: kept Verification run locally on the merged branch
The React Compiler check was skipped — no components or hooks were touched. |
|
Nothing to fix — every code check passes on the merged branch ( That job runs one step, Full check results at
|
| Check | Result |
|---|---|
typecheck, ESLint check, Oxfmt check, spellcheck |
Pass |
test (jobs 1–8), Bun tests, Storybook tests |
Pass |
React Compiler Compliance, Check for unused styles, Compare knip issues against main |
Pass |
baseline-perf-tests, branch-perf-tests |
Pass |
Android + iOS builds (build (Debug, true), build (developmentDebug, false), and the two Dev builds) |
Pass |
Check independent approval |
Fail — no approving review yet |
The same was true before the main merge: at f314fb7c9c0 every check passed except Verify peer review. So the merge introduced no regressions. I also re-ran npx tsc --noEmit locally on the merged branch — clean.
I didn't push anything, since there's no failure a code change could address.
| @@ -198,10 +198,15 @@ function convertPolicyEmployeesToApprovalWorkflows({policy, personalDetails, fir | |||
|
|
|||
| const member = buildMemberFromEmployee(employee, personalDetailsByEmail, email); | |||
There was a problem hiding this comment.
@MelvinBot move this line below early return to avoid redundant computation
There was a problem hiding this comment.
Done in b51b544edb0 — buildMemberFromEmployee now runs after the pendingAction === DELETE early return, so members pending deletion no longer build a Member that gets thrown away. Applied the same change in convertApprovalWorkflowRulesToWorkflows.
WorkflowUtilsTest.ts + WorkflowTest.ts + ApprovalWorkflowSectionTest.tsx (139 tests), lint-changed, and typecheck all pass.
| @@ -1608,10 +1603,14 @@ function convertApprovalWorkflowRulesToWorkflows({ | |||
|
|
|||
| const member = buildMemberFromEmployee(employee, personalDetailsByEmail, email); | |||
There was a problem hiding this comment.
@MelvinBot move this line below early return to avoid redundant computation
There was a problem hiding this comment.
Done in b51b544edb0 — buildMemberFromEmployee now runs after the pendingAction === DELETE early return here too, matching the same change in convertPolicyEmployeesToApprovalWorkflows.
WorkflowUtilsTest.ts + WorkflowTest.ts + ApprovalWorkflowSectionTest.tsx (139 tests), lint-changed, and typecheck all pass.
DetailsExplanation of ChangeWhen a member is removed while offline, the app first reassigns the default workflow's approver, which stamps
This change skips employees with The same fix is applied to One edge case is deliberately left alone: if no live employee has a resolvable Fixed Issues$ #99357 TestsPrecondition: a workspace with an Admin, Employee 1 set as the default approver, and Employee 2
Offline testsSame as Tests QA StepsSame as Tests
PR Author Checklist
@MelvinBot please set the PR body to the content in the details section above and mark as ready for review |
|
Still nothing to fix — every code check passes on the latest commit (
The PR is also still a draft. Full check results at
|
| Check | Result |
|---|---|
npm test -- tests/unit/WorkflowUtilsTest.ts tests/actions/WorkflowTest.ts tests/unit/ApprovalWorkflowSectionTest.tsx |
Passed (139 tests, 3 suites) |
npx tsc --noEmit |
Passed |
npx eslint src/libs/WorkflowUtils.ts tests/unit/WorkflowUtilsTest.ts |
Passed |
I didn't push anything — no code change would clear either of these.
|
@mkhutornyi 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] |
|
Done — the PR body is now set to the content you provided, and the PR is marked ready for review. Two sections from the previous body are gone because they weren't in the content you gave me: the |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppios.moviOS: mWeb SafariMacOS: Chrome / Safariweb.mov |
|
The failing Analysis: The error is Evidence
Next step: Someone needs to fix |
…lWorkflowOnDeletedMember Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
I merged the latest |
|
MelvinBot has made 5 consecutive commits trying to fix CI failures. Automatic CI fix dispatches are now paused for this PR. Next steps: A human should review the recent commits and resolve the conflicting CI errors manually. |
|
Only engineers should be merging code. @jasperhuangg @youssef-lr, can one of you merge? |
|
@mkhutornyi sorry there are conflicts now? @youssef-lr I think your internal engineer review on here should be enough, I'm going to unassign myself |
|
@MelvinBot pull main and fix conflict |
…lWorkflowOnDeletedMember Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com> # Conflicts: # src/libs/WorkflowUtils.ts # tests/unit/WorkflowUtilsTest.ts
|
I merged I resolved conflicts in these two files:
|
|
@MelvinBot pull main and fix conflict |
…lWorkflowOnDeletedMember Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com> # Conflicts: # src/libs/WorkflowUtils.ts
|
I merged How I resolved them:
All 148 tests in |
|
@MelvinBot pull main |
…lWorkflowOnDeletedMember Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
🚧 jasperhuangg has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/jasperhuangg in version: 9.5.9-0 🚀
|
|
🤖 No help site update is needed. This PR fixes a bug where an empty, phantom approval workflow row appeared after removing a member while offline, so the app now behaves as users would expect and no article sentence becomes incorrect. |
|
🚀 Deployed to production by https://github.com/cristipaval in version: 9.5.9-4 🚀
Bundle Size Analysis (Sentry): |












Explanation of Change
When a member is removed while offline, the app first reassigns the default workflow's approver, which stamps
submitsToon the member being removed, and then marks that member withpendingAction: DELETE. The stalesubmitsTosurvives until the backend confirms the removal.convertPolicyEmployeesToApprovalWorkflowscreated a workflow bucket for any employee with a resolvablesubmitsTo, but only pushed the employee into that bucket when theirpendingActionwas notDELETE. So the member pending deletion produced a workflow withmembers: []— the extra row showing "Approver: Admin, Expenses from: (nothing)". It also added that stale approver tousedApproverEmails, so the approver picker treated them as already in use by a workflow that no longer renders. Both disappear once online because the backend drops the removed employee entirely.This change skips employees with
pendingAction: DELETEat the top of the loop in both conversion functions, so they can't create a workflow they will never be a member of. A member pending deletion was already excluded fromavailableMembers, from workflowmembers, and from the workflow'spendingAction, so skipping them removes only the phantom workflow. The now-unreachableDELETEchecks further down each loop are removed as dead code.The same fix is applied to
convertApprovalWorkflowRulesToWorkflows(theMULTIPLE_APPROVERSbeta counterpart), which groups employees the same way and had the same defect.One edge case is deliberately left alone: if no live employee has a resolvable
submitsTo, the workflows list is now empty rather than showing the phantom row. That already matches existing behavior for a workspace where nobody submits to anyone (covered by the existingShould return an empty list if there are no employeesandShould not include users that submit to non-employee usertests), so it's not changed here.Fixed Issues
$ #99357
PROPOSAL: #99357 (comment)
Tests
Precondition: a workspace with an Admin, Employee 1 set as the default approver, and Employee 2
Offline tests
Same as Tests
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)Avatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.