Skip to content

Fix: keep the To-do row when only an older sibling expense report is fully held - #100784

Merged
inimaga merged 7 commits into
mainfrom
claude-todoHeldSiblingReport
Sep 21, 2026
Merged

inimaga merged 7 commits into
mainfrom
claude-todoHeldSiblingReport

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

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:

  1. getBadgeFromIOUReport now 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. Because getIOUReportActionWithBadge only 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 new getReportTransactions call — the existing one is hoisted and reused.

  2. The chat-wide all-held exclusion in getReasonAndReportActionThatRequiresAttention now 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 from originalMessage.linkedReportID while selection uses childReportID — 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 keeps requiresAttention === true for 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

  1. As an admin (account A), create a Collect or Control workspace and invite an employee (account B).
  2. In Workspace settings > Workflows, turn on Add approvals and set account A as the approver.
  3. As B, submit report 1 with a single expense to that workspace. Once it has submitted, submit report 2 with two expenses to the same workspace, so report 1 is the older of the two.
  4. As B, open report 1 and put its expense on hold.
  5. As A, open the To-dos tab in the LHN. Verify the workspace chat is still listed with an Approve badge, and that opening it lands on report 2 — the approvable sibling — not on the held report 1.
  6. As B, remove the hold from report 1 and instead put both expenses in report 2 on hold.
  7. As A, verify the To-dos row is still listed and its Approve badge now targets report 1.
  8. As B, remove the remaining holds. Verify A still sees the chat in To-dos.
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  1. As an admin (account A), create a Collect or Control workspace and invite an employee (account B).
  2. In Workspace settings > Workflows, turn on Add approvals and set account A as the approver.
  3. As B, submit report 1 with a single expense to that workspace. Once it has submitted, submit report 2 with two expenses to the same workspace, so report 1 is the older of the two.
  4. As B, open report 1 and put its expense on hold.
  5. As A, open the To-dos tab in the LHN. Verify the workspace chat is still listed with an Approve badge, and that opening it lands on report 2 — the approvable sibling — not on the held report 1.
  6. As B, remove the hold from report 1 and instead put both expenses in report 2 on hold.
  7. As A, verify the To-dos row is still listed and its Approve badge now targets report 1.
  8. As B, remove the remaining holds. Verify A still sees the chat in To-dos.
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

…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>
@MelvinBot

MelvinBot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Android test steps verification results: ⚠️ partial

Admin-side setup (workspace + employee invite + approver) verified on the standalone Android NewDot build. Steps 3–8 are blocked, not failed: every one of them needs a second, sign-in-capable Employee identity, and this run has exactly one authenticated account. The Android tester is scoped to a single pinned session and cannot mint a second account or run a sign-out/sign-in loop, because re-auth needs a magic code no CI run can read. Nothing was fabricated to fill the gap.

Workflows page showing Approver = Melvin Melvin for expenses from Everyone

Step Status
1. As an Admin, create a workspace and invite an Employee.Created workspace "Melvin Melvin's Workspace", then invited an employee address as a Member via Workspace > Members > Invite member. Post-invite Members list showed "Total workspace members: 2" with the invited address listed with role "Member".
Workspace Members list showing 2 total members after inviting the employee
✅
2. Set yourself (Admin) as the approver.Workspace > Workflows > Approvals default workflow reads "Expenses from: Everyone / Approver: Melvin Melvin" (the signed-in Admin/Owner account). No change was needed since the workspace creator is the default approver, but the state satisfies the check.
Workflows page showing Approver = Melvin Melvin for expenses from Everyone
✅
3. As the Employee, submit a single-expense report.Blocked. The invited Employee is a placeholder address with no reachable inbox, so its magic code cannot be retrieved. Driving this step needs either a second concurrent session or a sign-out/sign-in loop on the current one — both unsupported for this tester. No report was submitted.
❌
4. As the Employee, submit a separate report with two expenses.Blocked for the same reason as step 3 — requires authenticating as the second Employee account, unavailable in this single-session run.
❌
5. As the Employee, open the single-expense report and place the expense on hold.Blocked — depends on step 3's report existing and on being signed in as the Employee, neither achievable in this session.
❌
6. As the Admin, open the LHN To-dos tab and verify the two-expense report is still present with an Approve action.Blocked — there is no Employee-submitted two-expense report to check, since steps 3–5 could not be performed. No to-do row was fabricated to check against.
❌
7. Repeat with the hold on the newer report instead and verify the To-do row is still present.Blocked — requires the Employee-side report submission and hold actions from steps 3–5.
❌
8. With only one report, fully held by the Employee, verify the row is still excluded from the Admin's To-do tab.Blocked — requires the Employee to submit and fully hold a single report, which cannot be performed in this session.
❌

No console errors were observed during the steps that did run.

The core assertions of this PR (steps 6–8) are exactly the ones that need two users, so this run does not exercise the fix. Verifying it on Android needs a second real, sign-in-capable Employee account provisioned by the CI session harness. In the meantime, the regression tests in tests/unit/ReportUtilsTest.ts cover the same two-child-report scenario without needing a second live account.


view run · view recording

@MelvinBot

MelvinBot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor Author

Fixed. The only real failure was the Oxfmt check — two lines in this PR weren't formatted the way oxfmt wants. Pushed 295696a with the reformat; Oxfmt now passes and every other check is green.

The remaining Check independent approval failure is a human-review gate, not something I can resolve by pushing code.

Details

Failure: Oxfmt check ran npm run fmt and found a diff in the two files this PR touches:

src/libs/ReportUtils.ts
src/libs/actions/IOU/ReportWorkflow.ts
Error: Oxfmt diff detected! Please run `npm run fmt` and commit the changes.

Fix: whitespace only — no logic change. oxfmt split the isExcludedForHeldExpenses condition in src/libs/ReportUtils.ts:4665 across three lines, and joined the hasOnlyHeldExpenses condition in src/libs/actions/IOU/ReportWorkflow.ts:344 onto one. Net: 4 insertions, 3 deletions.

AI tests run locally before pushing:

Test Result
npm run fmt (re-run, idempotent) ✅ clean
npm run typecheck ✅ pass
npm test -- tests/unit/ReportUtilsTest.ts ✅ 1325 passed
npx eslint on both changed files ⚠️ only pre-existing violations (no-onyx-connect, no-deprecated, no-unsafe-type-assertion) on lines this PR never touched — the CI ESLint check passes
npm run lint-changed ⚠️ could not run — git merge-base fails against the shallow checkout in this environment
npm run prettier ⚠️ script no longer exists; the repo formats with oxfmt

view run · no recording available

@MelvinBot

MelvinBot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Web test steps verification results: ⚠️ partial

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.

Workflows page showing Approver set to Melvin Tester (Admin)

Step Status
1. As an Admin, create a workspace and invite an Employee.Created workspace "Melvin Tester's Workspace" (Collect plan, USD) via Workspaces > New workspace > Confirm. Invited an employee address as a Member; the workspace Members list now shows two rows: "Melvin Tester … Owner" and the invited address … Member.
Confirmed new workspace 'Melvin Tester's Workspace' overview page
Members list showing invited Employee alongside the Admin/Owner
✅
2. Set yourself (Admin) as the approver.Workspace > Workflows shows Approvals enabled with the default workflow "Expenses from: Everyone / Approver: Melvin Tester" (the signed-in Admin/Owner account), confirming the Admin is configured as the approver for the workspace.
Workflows page showing Approver set to Melvin Tester (Admin)
✅
3. As the Employee, submit a single-expense report.Blocked. Requires signing in as the invited Employee, which has no mailbox Melvin can access to complete magic-code sign-in, and would require a second concurrent session/identity beyond the single pinned session. This step could not be executed.
❌
4. As the Employee, submit a separate report with two expenses.Blocked — same blocker: no accessible second Employee identity/session to drive this action.
❌
5. As the Employee, open the single-expense report and place the expense on hold.Blocked — depends on step 3's Employee-submitted single-expense report, which is blocked for the same reason.
❌
6. As the Admin, open the LHN To-dos tab and verify the two-expense report is still present with an Approve action.Blocked — depends on the Employee having submitted both reports and placed a hold. There is no data to verify this LHN state against, and no to-do row was fabricated.
❌
7. Repeat with the hold on the newer report instead and verify the To-do row is still present.Blocked — depends on Employee-driven report submission and hold actions.
❌
8. With only one report, fully held by the Employee, verify the row is still excluded from the Admin's To-do tab.Blocked — depends on Employee-driven report submission and full hold.
❌

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 tests/unit/ReportUtilsTest.ts cover the same two-child-report scenario without a second live account.


view run · view recording

Comment thread src/libs/actions/IOU/ReportWorkflow.ts Outdated
Comment on lines +344 to +346
if (
hasOnlyHeldExpenses(reportTransactions) &&
(isOpenExpenseReportReportUtils(iouReport) || !didCurrentUserPlaceHoldOnReportExpense(getAllReportActions(iouReport?.reportID), reportTransactions, currentUserAccountID))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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>
Comment thread src/libs/actions/IOU/ReportWorkflow.ts Outdated
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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 — passed
  • npm test -- tests/actions/IOUTest/ReportWorkflowTest.ts tests/unit/ReportUtilsTest.ts — 1418 passed
  • npm 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.

Comment thread src/libs/ReportUtils.ts Outdated
Comment on lines +4949 to +4957
function isExcludedForHeldExpenses(
iouReport: OnyxEntry<Report>,
iouReportActions: OnyxEntry<ReportActions>,
reportTransactions: Transaction[],
currentUserAccountID: number | undefined,
): boolean {
return hasOnlyHeldExpenses(reportTransactions) && (isOpenExpenseReport(iouReport) || !didCurrentUserPlaceHoldOnReportExpense(iouReportActions, reportTransactions, currentUserAccountID));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MelvinBot Let's remove this function. It's ok to make duplicated logic as before

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 original hasAllExpensesHeld / iouReportActions locals, 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 in getBadgeFromIOUReport.

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 — passed
  • npm test -- tests/actions/IOUTest/ReportWorkflowTest.ts tests/unit/ReportUtilsTest.ts — 1418 passed
  • npm 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.

MelvinBot and others added 2 commits September 16, 2026 12:50
…only

Co-authored-by: DylanDylann <DylanDylann@users.noreply.github.com>
…red helper

Co-authored-by: DylanDylann <DylanDylann@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

No code fix is needed — every check that CI can decide on its own is green on e0b24dd5. The two red checks are both human-review gates that no push can satisfy.

Failing check Why Who unblocks it
Check independent approval approvers: [], independentApprovers: [] — the PR has six COMMENTED reviews and zero APPROVED ones A reviewer submits an approving review
checklist (PR Reviewer Checklist) No PR Reviewer Checklist was found — it scanned all 9 comments and none is the reviewer checklist The reviewer posts the checklist comment
Everything else on e0b24dd5

The full suite finished after your request came in — the earlier "failures" you saw were partly jobs still pending. Final state:

  • Jest Unit Tests — all 8 shards pass, plus Storybook tests. This is the one I actually wanted to see, because e0b24dd5 dropped the getAllReportActions fallback in getIOUReportActionWithBadge, and three callers of getReasonAndReportActionThatRequiresAttention don't pass allReportActions. No test regressed.
  • Reassure Performance Tests — baseline-perf-tests and branch-perf-tests both pass.
  • Remote Build Android / Remote Build iOS — all build jobs pass.
  • typecheck, ESLint check, Oxfmt check, Bun tests, spellcheck, Knip check, React Compiler Compliance, Check for unused styles, verifySignedCommits, CLA — all pass.

I pushed nothing, since there is no failure attributable to the diff.


view run

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Still nothing for me to fix. 0e539308 — the commit that inlined the held-expense exclusion and dropped the shared helper — is green across the whole suite. The same two checks are red, and both are human-review gates rather than anything a push can change:

Failing check Error Who unblocks it
Check independent approval does not have enough independent eligible reviewer approvals — approvers: [], independentApprovers: [] A reviewer submits an approving review
checklist (PR Reviewer Checklist) No PR Reviewer Checklist was found across all 10 comments The reviewer posts the checklist comment
Full check state on 0e539308

Every automated check passes, including the ones most likely to catch the helper removal:

  • Jest Unit Tests — all 8 shards pass, plus Storybook tests.
  • typecheck and ESLint check — pass. The exclusion is now a local const isExcludedForHeldExpenses at src/libs/actions/IOU/ReportWorkflow.ts:345, with the other copy inlined at src/libs/ReportUtils.ts:4661; no exported helper is left behind.
  • Compare knip issues against main — passes, which is what would have flagged a now-unused export if the removal had been incomplete.
  • Reassure Performance Tests — baseline-perf-tests, branch-perf-tests, and validate-perf-tests all pass.
  • Remote Build Android / Remote Build iOS — all four build jobs pass.
  • Oxfmt check, Bun tests, spellcheck, React Compiler Compliance, Check for unused styles, verifySignedCommits, codecov/patch, codecov/project, CLA — pass.

The only non-green entries besides the two above are jobs reporting skipping, which is their normal state on a PR of this shape.


view run

Comment thread src/libs/ReportUtils.ts Outdated
Comment on lines +4651 to +4652
// 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


view run

@DylanDylann

Copy link
Copy Markdown
Contributor

@MelvinBot Please mark this PR as ready to review

@DylanDylann

Copy link
Copy Markdown
Contributor

@MelvinBot I've verified that the Tests section is correct. Please also fill out the QA section

@DylanDylann

DylanDylann commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Screen.Recording.2026-09-18.at.15.33.50.mov
Android: mWeb Chrome
Screen.Recording.2026-09-18.at.14.58.47.mov
iOS: HybridApp
Screen.Recording.2026-09-18.at.15.00.23.mov
iOS: mWeb Safari
Screen.Recording.2026-09-18.at.14.58.09.mov
MacOS: Chrome / Safari
Screen.Recording.2026-09-18.at.14.55.11.mov

Co-authored-by: DylanDylann <DylanDylann@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

⚠️ MelvinBot CI Fix Loop Detected

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.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

QA Steps are filled out. I also promoted the Tests section out of its // TODO: block now that you've verified those steps.

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 ReportWorkflow.ts:330-352).

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:

  • Offline tests is still empty. This change only re-derives the LHN To-do row from data already in Onyx and makes no new API calls, so there's nothing offline-specific to assert — but whether to write that down or leave it blank is your call.
  • The PR Author Checklist boxes are all still unchecked.

view run

@DylanDylann

Copy link
Copy Markdown
Contributor

@MelvinBot Please update both the Tests and QA sections to use this test step

  1. As an admin (account A), create a Collect or Control workspace and invite an employee (account B).
  2. In Workspace settings > Workflows, turn on Add approvals and set account A as the approver.
  3. As B, submit report 1 with a single expense to that workspace. Once it has submitted, submit report 2 with two expenses to the same workspace, so report 1 is the older of the two.
  4. As B, open report 1 and put its expense on hold.
  5. As A, open the To-dos tab in the LHN. Verify the workspace chat is still listed with an Approve badge, and that opening it lands on report 2 — the approvable sibling — not on the held report 1.
  6. As B, remove the hold from report 1 and instead put both expenses in report 2 on hold.
  7. As A, verify the To-dos row is still listed and its Approve badge now targets report 1.
  8. As B, remove the remaining holds. Verify A still sees the chat in To-dos.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

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 isExcludedForHeldExpenses, but that helper was removed in 0e539308 per your earlier review. It now reads "the chat-wide all-held exclusion". No other part of the body changed.


view run

@DylanDylann

Copy link
Copy Markdown
Contributor

@MelvinBot Please mark this PR as ready to review

@MelvinBot
MelvinBot marked this pull request as ready for review September 18, 2026 09:11
@MelvinBot
MelvinBot requested a review from a team as a code owner September 18, 2026 09:11
@melvin-bot

melvin-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown

@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]

@melvin-bot
melvin-bot Bot removed request for a team and trjExpensify September 18, 2026 09:11
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Done — this PR is out of draft and ready for review.

Two things still need a human before it can merge:

  1. Tests and QA Steps are still // TODO placeholders in the description. I can't fill those out on your behalf. The suggested manual steps from the linked issue are already listed there as comments — please convert them into the real sections.
  2. Author checklist is unchecked, including the all-platform screenshots.

Checks are green apart from Check independent approval, which just needs a reviewer. typecheck, ESLint check, spellcheck, React Compiler Compliance, and all 8 Jest shards pass on 73fe723f.


view run

Comment thread src/libs/actions/IOU/ReportWorkflow.ts Outdated
// 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 =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MelvinBot Fix this issue

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 8bca960b. The predicate now lives in one place — ReportUtils.ts:4938-4948 — and both sites call it:

  • ReportWorkflow.ts:342 in getBadgeFromIOUReport
  • ReportUtils.ts:4663 in getReasonAndReportActionThatRequiresAttention, still gated on !iouReportActionToApproveOrPay so 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 — passed
  • npm 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 passed
  • eslint on both files — 110 errors, all pre-existing and ratcheted; unchanged from before this commit (103 in ReportUtils.ts, 7 in ReportWorkflow.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.


view run

…xpenses helper

Co-authored-by: DylanDylann <DylanDylann@users.noreply.github.com>
@MelvinBot
MelvinBot requested a review from a team as a code owner September 21, 2026 07:56
@melvin-bot
melvin-bot Bot requested review from inimaga and removed request for a team September 21, 2026 07:57
@melvin-bot

melvin-bot Bot commented Sep 21, 2026

Copy link
Copy Markdown

@inimaga 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]

@DylanDylann

Copy link
Copy Markdown
Contributor

@inimaga All yours

@inimaga inimaga left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@inimaga
inimaga merged commit bd76eb5 into main Sep 21, 2026
44 of 47 checks passed
@inimaga
inimaga deleted the claude-todoHeldSiblingReport branch September 21, 2026 15:38
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

Copy link
Copy Markdown
Contributor

🚧 inimaga has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/inimaga in version: 9.4.91-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 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 checked

What the PR changes

  • src/libs/actions/IOU/ReportWorkflow.ts — getBadgeFromIOUReport now withholds a badge from a fully-held report, so a held child can't win the "oldest action" race.
  • src/libs/ReportUtils.ts — the chat-wide all-held exclusion now runs only on the fallback path, via the new shared isReportExcludedForHeldExpenses helper.

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 docs/articles

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 @MelvinBot document how holds affect the To-dos tab and I'll open the draft docs PR.

@DylanDylann, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review — note that I did not create one, since I found no required help site change, so there is nothing to review unless you disagree with the assessment above.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/lakchote in version: 9.4.91-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants