Repository navigation
Fix: keep the To-do row when only an older sibling expense report is fully held - #100784
Conversation
…fully held An all-held report is now withheld from producing an action badge in getBadgeFromIOUReport, so it can no longer win the oldest-action race in getIOUReportActionWithBadge and hide a sibling report that still needs approval. The chat-wide held-expenses gate in getReasonAndReportActionThatRequiresAttention now only applies on the fallback path, where no badge candidate was selected. Co-authored-by: DylanDylann <DylanDylann@users.noreply.github.com>
Co-authored-by: DylanDylann <DylanDylann@users.noreply.github.com>
|
Fixed. The only real failure was the Oxfmt check — two lines in this PR weren't formatted the way The remaining DetailsFailure: Fix: whitespace only — no logic change. AI tests run locally before pushing:
view run · no recording available |
|
🤖 Web test steps verification results: Steps 1–2 (Admin-only: create workspace, invite Employee, confirm Admin as approver) were driven and verified on web. Steps 3–8 are blocked: each needs a genuine second Employee identity to submit and hold expense reports, and this run has one pinned session with one account. The invited Employee address has no mailbox Melvin can reach for magic-code sign-in, and a second session or a sign-out/sign-in loop is outside the tester's scope. Nothing was fabricated to fill the gap.
No console errors were observed during the steps that did run. Same outcome as the Android run: the PR's core assertions (steps 6–8) are exactly the ones needing two users, so neither platform run exercises the fix. Verifying it end-to-end needs a second real, sign-in-capable Employee account provisioned by the CI session harness. Until then, the regression tests in |
| if ( | ||
| hasOnlyHeldExpenses(reportTransactions) && | ||
| (isOpenExpenseReportReportUtils(iouReport) || !didCurrentUserPlaceHoldOnReportExpense(getAllReportActions(iouReport?.reportID), reportTransactions, currentUserAccountID)) |
There was a problem hiding this comment.
@MelvinBot Don't use getAllReportActions, we need to pass it as a parameter. Also, this logic looks duplicated in the getReasonAndReportActionThatRequiresAttention function. Could we process it just once?
…eFromIOUReport Co-authored-by: DylanDylann <DylanDylann@users.noreply.github.com>
| actionBadge = badge; | ||
| } | ||
| // Prefer the caller's own report-actions snapshot for the same reason we prefer its `allReports` above. | ||
| const iouReportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.reportID}`] ?? getAllReportActions(iouReport.reportID); |
There was a problem hiding this comment.
| const iouReportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.reportID}`] ?? getAllReportActions(iouReport.reportID); | |
| const iouReportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.reportID}`] |
@MelvinBot Don't use getAllReportActions
There was a problem hiding this comment.
Done in e0b24dd5. getIOUReportActionWithBadge now resolves the child's actions from the passed-in collection only — ReportWorkflow no longer reads report actions out of Onyx on this path.
One thing worth calling out: getIOUReportActionWithBadge's allReportActions parameter is optional, and three callers of getReasonAndReportActionThatRequiresAttention don't supply it (requiresAttentionFromCurrentUser, useOptimisticNextStep, DebugUtils). With the fallback gone those paths would have passed undefined actions, which silently flips the hold-creator carve-out — didCurrentUserPlaceHoldOnReportExpense returns false with no actions, so an all-held report would lose its badge even for the person who placed the hold. So the call site now passes allReportActionsParam ?? allReportActions, reusing the module-level collection ReportUtils already maintains. The caller's snapshot still wins when there is one, so the fresh-data preference is unchanged — the Onyx read just moved to the layer that already had the data.
Tests run
npm run typecheck— passednpm test -- tests/actions/IOUTest/ReportWorkflowTest.ts tests/unit/ReportUtilsTest.ts— 1418 passednpm test -- tests/unit/reportAttributesTest.ts tests/unit/SidebarUtilsTest.ts tests/unit/shouldFollowActionBadgeTargetTest.ts— 144 passed- ESLint on both changed files — no violations on the changed lines
The existing getIOUReportActionWithBadge tests call it without allReportActions and still pass, so none of them depended on the Onyx fallback.
npm run lint-changed and npm run spell-changed couldn't run in this environment — they need a git merge-base against origin/main and this is a shallow clone. CI covers both.
| function isExcludedForHeldExpenses( | ||
| iouReport: OnyxEntry<Report>, | ||
| iouReportActions: OnyxEntry<ReportActions>, | ||
| reportTransactions: Transaction[], | ||
| currentUserAccountID: number | undefined, | ||
| ): boolean { | ||
| return hasOnlyHeldExpenses(reportTransactions) && (isOpenExpenseReport(iouReport) || !didCurrentUserPlaceHoldOnReportExpense(iouReportActions, reportTransactions, currentUserAccountID)); | ||
| } | ||
|
|
There was a problem hiding this comment.
@MelvinBot Let's remove this function. It's ok to make duplicated logic as before
There was a problem hiding this comment.
Removed in 0e539308. isExcludedForHeldExpenses is gone along with its export, and the expression is inlined at both call sites the way it was before:
ReportUtils.ts:4661-4672— back to the originalhasAllExpensesHeld/iouReportActionslocals, with!iouReportActionToApproveOrPay &&kept in front so it still only runs on the fallback path.ReportWorkflow.ts:342-350— the same expression as a local const ingetBadgeFromIOUReport.
ReportWorkflow now imports didCurrentUserPlaceHoldOnReportExpense from ReportUtils; that one was already exported before this PR, so no new export was added.
Tests run
npm run typecheck— passednpm test -- tests/actions/IOUTest/ReportWorkflowTest.ts tests/unit/ReportUtilsTest.ts— 1418 passednpm test -- tests/unit/reportAttributesTest.ts tests/unit/SidebarUtilsTest.ts tests/unit/shouldFollowActionBadgeTargetTest.ts— 144 passed- ESLint on both changed files — no violations on the changed lines
npm run lint-changed and npm run spell-changed couldn't run here — they need a git merge-base against origin/main and this is a shallow clone. CI covers both.
…only Co-authored-by: DylanDylann <DylanDylann@users.noreply.github.com>
…red helper Co-authored-by: DylanDylann <DylanDylann@users.noreply.github.com>
|
No code fix is needed — every check that CI can decide on its own is green on
Everything else on
|
|
Still nothing for me to fix.
Full check state on
|
| // getIOUReportActionWithBadge reads each child report's actions straight out of this collection, so fall back to | ||
| // the module cache here rather than letting it reach into Onyx itself. |
There was a problem hiding this comment.
| // getIOUReportActionWithBadge reads each child report's actions straight out of this collection, so fall back to | |
| // the module cache here rather than letting it reach into Onyx itself. |
There was a problem hiding this comment.
Removed in 73fe723f. The allReportActionsParam ?? allReportActions argument is now passed with no comment above it — ReportUtils.ts:4648-4652.
Comment-only deletion, no behavior change. eslint src/libs/ReportUtils.ts reports the same 103 pre-existing (ratcheted) errors as before, none near this call site.
|
@MelvinBot Please mark this PR as ready to review |
|
@MelvinBot I've verified that the Tests section is correct. Please also fill out the QA section |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2026-09-18.at.15.33.50.movAndroid: mWeb ChromeScreen.Recording.2026-09-18.at.14.58.47.moviOS: HybridAppScreen.Recording.2026-09-18.at.15.00.23.moviOS: mWeb SafariScreen.Recording.2026-09-18.at.14.58.09.movMacOS: Chrome / SafariScreen.Recording.2026-09-18.at.14.55.11.mov |
Co-authored-by: DylanDylann <DylanDylann@users.noreply.github.com>
|
MelvinBot has made 6 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. |
|
QA Steps are filled out. I also promoted the Tests section out of its Tests — the eight suggested steps, plus two I added: a sanity check that the row still shows when nothing is held, and a carve-out check that an all-held report whose hold was placed by the approver stays in their To-dos (that's the branch in QA Steps — the same coverage written to be self-contained for a QA engineer on staging: setup, then the four cases (older sibling held, newer sibling held, nothing held, all-held single report) and the approver-hold carve-out, with the admin-side verification repeated on all five platforms. Two things still need you, since they're author attestations I shouldn't make on your behalf:
|
|
@MelvinBot Please update both the Tests and QA sections to use this test step
|
|
Done — both the Tests and QA Steps sections now contain your 8 steps verbatim, nothing added. The body had picked up a longer variant of these steps (10 numbered items under Tests, a 15-step regrouped version under QA). Both are gone, replaced by exactly what you pasted. One unrelated line I also corrected while rewriting the body: the Explanation of Change still described the chat-wide gate as |
|
@MelvinBot Please mark this PR as ready to review |
|
@DylanDylann 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 — this PR is out of draft and ready for review. Two things still need a human before it can merge:
Checks are green apart from |
| // An all-held report can't move to its next state, so it doesn't get an action badge. Keep it only for a report | ||
| // awaiting approval or payment where the current user placed a hold, since they can remove it. An open report stays | ||
| // excluded because only its owner can place a hold there, and that owner is the one who submits. | ||
| const isExcludedForHeldExpenses = |
There was a problem hiding this comment.
❌ CONSISTENCY-3 (docs)
This PR introduces the same all-held exclusion condition in two places: here in getBadgeFromIOUReport (hasOnlyHeldExpenses(reportTransactions) && (isOpenExpenseReportReportUtils(iouReport) || !didCurrentUserPlaceHoldOnReportExpense(iouReportActions, reportTransactions, currentUserAccountID))) and again in getReasonAndReportActionThatRequiresAttention in src/libs/ReportUtils.ts (isFallbackReportExcludedForHeldExpenses, the same predicate with hasAllExpensesHeld/isOpenExpenseReport). The two copies must now be kept in sync, and if the carve-out for who can remove a hold ever changes, both have to change together, raising the risk they drift apart and reintroduce the very bug this PR fixes.
Extract the shared predicate into one helper and call it from both sites, e.g.:
function isReportExcludedForHeldExpenses(
iouReport: OnyxEntry<OnyxTypes.Report>,
transactions: OnyxTypes.Transaction[],
iouReportActions: OnyxEntry<OnyxTypes.ReportActions>,
currentUserAccountID: number,
): boolean {
return hasOnlyHeldExpenses(transactions) && (isOpenExpenseReport(iouReport) || !didCurrentUserPlaceHoldOnReportExpense(iouReportActions, transactions, currentUserAccountID));
}Then both getBadgeFromIOUReport and the fallback path in getReasonAndReportActionThatRequiresAttention call it, so the rule lives in one place.
Reviewed at: 73fe723 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
Done in 8bca960b. The predicate now lives in one place — ReportUtils.ts:4938-4948 — and both sites call it:
ReportWorkflow.ts:342ingetBadgeFromIOUReportReportUtils.ts:4663ingetReasonAndReportActionThatRequiresAttention, still gated on!iouReportActionToApproveOrPayso it only runs on the fallback path
No behavior change — same operands, same short-circuit order. ReportWorkflow no longer imports didCurrentUserPlaceHoldOnReportExpense; the helper wraps it.
Worth flagging: on Sep 16 you asked me to delete exactly this kind of helper ("It's ok to make duplicated logic as before"), which is why the duplication is here. This puts it back under a different name. Say the word if you'd rather keep the duplication and dismiss the bot's finding instead, and I'll revert.
Tests run
npm run typecheck— passednpm test -- tests/actions/IOUTest/ReportWorkflowTest.ts tests/unit/ReportUtilsTest.ts tests/unit/TodosUtilsTest.ts tests/unit/reportAttributesTest.ts tests/unit/SidebarUtilsTest.ts tests/unit/shouldFollowActionBadgeTargetTest.ts— 1588 passedeslinton both files — 110 errors, all pre-existing and ratcheted; unchanged from before this commit (103 inReportUtils.ts, 7 inReportWorkflow.ts), none on the changed lines
npm run lint-changed / spell-changed couldn't run here (they need a git merge-base against origin/main, and this is a shallow clone). CI covers both.
I also spotted the same all-held + hold-creator pairing in TodosUtils.ts:209-211 and TodosUtils.ts:271-273, but it's a different shape (no isOpenExpenseReport term, feeds a per-bucket context) and predates this PR, so I left it alone.
…xpenses helper Co-authored-by: DylanDylann <DylanDylann@users.noreply.github.com>
|
@inimaga All yours |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 inimaga 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! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/inimaga in version: 9.4.91-0 🚀
|
|
🤖 No help site changes are required for this PR, so no draft docs PR was created. This PR is a behavior-restoring bug fix in internal LHN/To-do selection logic. It changes no feature, tab, setting, label, or button, and it introduces no new user-facing concept to document. How I checkedWhat the PR changes
Net user-visible effect: a workspace chat that still has an approvable expense report stays in To-dos with its Approve badge, instead of disappearing because an older sibling report was fully held. That is the already-documented behavior, not a new one. Docs I searched under
No article documents the hold-based To-do exclusion that [Payment due @eh2077] Exclude all-held reports from the Inbox to-do, keep them for whoever placed the hold introduced, so there is nothing stale to correct now that its behavior has been narrowed. If you'd like it documented anyway: the gap is that no help article explains how holds interact with the To-dos tab and the For you section. That is a pre-existing gap, not something this PR created. Reply with @DylanDylann, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR |
|
🚀 Deployed to production by https://github.com/lakchote in version: 9.4.91-3 🚀
Bundle Size Analysis (Sentry): |





Explanation of Change
For a workspace admin, the To-do row is the policy expense chat, not each expense report, so several child expense reports share one LHN row. That row picks a single representative child and applies the all-held exclusion to it, then uses the result to gate the whole chat. When the oldest child was fully held, the chat dropped out of the To-do tab and took a still-approvable sibling's pending approval with it.
Two changes:
getBadgeFromIOUReportnow withholds an action badge from an all-held report, keeping the same carve-out the LHN already had: a report awaiting approval or payment where the current user placed a hold is still badged, since only they can remove it, and an open report stays excluded because only its owner can hold there. BecausegetIOUReportActionWithBadgeonly considers previews that yield a badge, a fully-held child can no longer win the "oldest action" race, and an approvable sibling wins instead. This adds no newgetReportTransactionscall — the existing one is hoisted and reused.The chat-wide all-held exclusion in
getReasonAndReportActionThatRequiresAttentionnow only applies on the fallback path, when no badge candidate was selected. A selected candidate has already been vetted for holds, and the gate derived its report fromoriginalMessage.linkedReportIDwhile selection useschildReportID— evaluating it twice could re-target the held sibling and reintroduce the bug.The exclusion itself came from #96178 and is unchanged in intent; it just now runs during candidate selection instead of after a single winner was chosen.
Regression tests added in
tests/unit/ReportUtilsTest.ts: a chat with two submitted child reports where the older one is fully held by the submitter keepsrequiresAttention === truefor the approver, and the badge action points at the approvable sibling rather than the held report. The existing single-report exclusion tests from #96178 still pass unchanged.Fixed Issues
$ #100365
PROPOSAL: #100365 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, 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