Repository navigation
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safaritest1.movweb.mov |
| const submitterRules = rulesBySubmitter.get(submitter) ?? {}; | ||
| submitterRules[ruleID] = rule; | ||
| rulesBySubmitter.set(submitter, submitterRules); |
There was a problem hiding this comment.
NAB: redundant Map.set on every iteration
rulesBySubmitter.set runs for every rule and submitter pair, even when the submitter's entry already exists.
let submitterRules = rulesBySubmitter.get(submitter);
if (!submitterRules) {
submitterRules = {};
rulesBySubmitter.set(submitter, submitterRules);
}
submitterRules[ruleID] = rule;| const submitterRules = rulesBySubmitter.get(email) ?? {}; | ||
| const hasInitialRule = !!resolveFirstApprover(email, submitterRules, {}); | ||
| if (!hasInitialRule && !submitsTo) { | ||
| continue; | ||
| } | ||
|
|
||
| let chain = buildApproverChainFromRules({submitter: email, rules, employees, personalDetailsByEmail}).map((approver) => ({ | ||
| let chain = buildApproverChainFromRules({submitter: email, rules: submitterRules, employees, personalDetailsByEmail}).map((approver) => ({ |
There was a problem hiding this comment.
NAB: nothing locks in the "only the submitter's rules" assumption
This is only correct while resolveApprovalHop and buildApproverChainFromRules never read rules for other submitters.
If a later change makes a step read an approver's own submit rules, this caller would silently build wrong chains.
Could we add a unit test? Two submitters share approver A, A submits to B through their own rules, and the result must match passing all rules. Or at least note the assumption in the JSDoc on buildApproverChainFromRules.
|
Author Checklist failing |
|
@MelvinBot assign me in the linked issue |
|
Assigned |
Is this step correct? I don't see red dot but instead approver is replaced with owner |
|
Worth follow-up: same full-rules scan left in the two sibling functions Lines 1923 to 1955 in 840fa7c Lines 1964 to 1981 in 840fa7c
|
|
I found weird bug which also happens on production. web2.mov |
JmillsExpensify
left a comment
There was a problem hiding this comment.
No product review required.
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #107403 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
mountiny
left a comment
There was a problem hiding this comment.
@MelvinBot can you create issue to address the NAB follow ups and assign @TMisiukiewicz @situchan and @mountiny
|
Created Approval workflow rules: address non-blocking review follow-ups and assigned Includes the redundant map writes, regression coverage, and sibling-function optimization. |
…s-by-submitter Speed up building approval workflows from rules (cherry picked from commit 504bf8d) (cherry-picked to staging by mountiny)
|
🚀 Cherry-picked to staging by https://github.com/mountiny in version: 9.5.43-2 🚀
|
|
No help site update needed — this PR only optimizes approval workflow calculations without changing user-facing behavior, adding a feature, or removing a beta gate. |
|
🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
…s-by-submitter Speed up building approval workflows from rules (cherry picked from commit 504bf8d) (cherry-picked to production by mountiny)
|
🚀 Cherry-picked to staging by https://github.com/mountiny in version: 9.5.47-0 🚀
|
|
🚀 Deployed to production by https://github.com/marcaaron in version: 9.5.45-0 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
On accounts with the Multiple Approvers beta, rebuilding approval workflows from rules was slow on large workspaces. For each member, every step of the approval chain scanned all of the workspace's rules and re-read each rule's submitter list, even though only the rules that list that member can apply.
This runs every time the Workspaces tab red dot is recalculated. In a profile on a large account, one report open merged ~115 policies and spent ~1.5s blocking the JS thread in this code. About 1.07s of that was re-reading rule submitter lists.
convertApprovalWorkflowRulesToWorkflowsalready loops over every rule once to collect submitters. It now also groups the rules by submitter in that same loop.Fixed Issues
$ #107403
PROPOSAL:
Tests
main.Onyx.merge('policy_<policyID>', {approvalMode: 'ADVANCED', employeeList: {'<member email>': {submitsTo: 'removed-approver@example.com'}}})in the browser console, then open Workflows. Verify that approver is flagged as no longer a member, and the Workspaces tab shows a red dot.Offline tests
Same as tests, but with the network connection turned off. Verify the app behaves the same and no errors appear.
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)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.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
🤖 Generated with Claude Code