[NoQA] feat: add canMergeReports eligibility helper for the Merge Reports project#94939
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c78d96bfd6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1e361dde2d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1e361dde2d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
situchan
left a comment
There was a problem hiding this comment.
We have similar logic:
Line 2971 in 989d3ea
It already encodes per-report merge eligibility (owner vs. admin vs. manager × Open/Processing/awaiting-approval states).
The new canMergeReports re-implements overlapping logic (owner/admin/approver + state gating) instead of calling it per report.
Worth checking whether canMergeReports should be selectedReports.every(r => isMoneyRequestReportEligibleForMerge(r, isAdmin)) plus the cross-report invariants (same owner/policy/state/manager), rather than a parallel hand-rolled permission check that can drift from the existing one.
|
@situchan Thanks. Updated |
|
@codex review |
Review:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c2a599eb77
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // the same managerID so the merged report lands in exactly one approver's | ||
| // inbox. For Open reports the managerID may legitimately be unset, but the | ||
| // same-state constraint above already prevents mixing Open and Processing. | ||
| if (isProcessingReport(report)) { |
There was a problem hiding this comment.
Validate approver parity for draft reports
This only enforces a shared managerID after reports are already Processing, but draft/open expense reports are not guaranteed to share an approver just because they have the same owner and policy. getSubmitToAccountID() can choose a rule approver from each report's own transaction category/tag approval rules, so two Open reports on the same workspace can route to different approvers; this helper would return true and let a merge collapse those expenses into a single approval path.
Useful? React with 👍 / 👎.
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #94870 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
|
🚧 mollfpr 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/mollfpr in version: 9.4.28-0 🚀
|
No help site changes requiredI reviewed the changes in this PR against Why: This PR is internal groundwork for the Merge Reports project. It only adds the
Help articles document behavior users can see and act on. Since nothing user-facing is exposed here, there's nothing to document yet. Documentation should be authored when the Merge Reports feature actually surfaces in the UI (with the real button labels, menu paths, and flow), so the help content matches the live experience. I also confirmed there is no existing article covering "merge expense reports" — the current "merge" articles (e.g. If a later PR in this project ships the user-facing merge flow, that's the right point to tag me to create the help site update. @dmkt9, this is a heads-up that no docs PR was created. If you believe a user-facing behavior did change here and warrants documentation, let me know and I'll draft it. |
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.4.28-2 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
Determines whether the current user is eligible to initiate a merge of the selected expense reports.
Returns
falseif ANY of the following conditions hold:ownerAccountIDs— cross-account merges are not supported.policyIDs— cross-workspace merges are not supported in v1.stateNum / statusNum) — only reports at the same point in the approval workflow can be merged, preventing an Open draft from being silently merged onto a Processing report and thereby bypassing approvals.managerIDs— each report must be waiting on the same approver so that the combined report lands in exactly one inbox. (This check is redundant for Open reports: the same-state rule above already prevents mixing Open and Processing, and same-account + same-workspace already guarantees a matching managerID for drafts.)canUserPerformWriteAction, or the current user is neither the report owner nor an admin / approver with write access to that report.NOTE: This function only checks eligibility to START the merge flow. The merge destination (the report that absorbs the others) is chosen later in the RHP and is not validated here.
Fixed Issues
$ #94870
PROPOSAL:
Tests
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
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.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari