App icon indicating copy to clipboard operation
App copied to clipboard

[Due for payment 2026-11-25] [$250] To do - The employee held report displays in To do tab

Open applause-bot[bot] opened this issue 2 months ago β€’ 166 comments

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: v9.4.95-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/76118654/folder/57610718/132213353/1807068739?sort=-identifier Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: Win 11/Chrome App Component: Money Requests

Action Performed:

Preconditions:

  • User A (Employee) is a member of a workspace where User B (Approver/Admin) is set as the approver
  • Workspace has approvals enabled
  1. Open https://staging.new.expensify.com
  2. User A navigate to the workspace chat
  3. User A create and submit a single-expense
  4. User A hold this expense
  5. At another browser, User B open the Inbox page (don't click on user A's report)
  6. Click on To-dos tab

Expected Result:

Verify the single-expense report is not present in the Inbox To-do tab and does not show a green Approve badge

Actual Result:

The single-expense report with a green dot is present in the Inbox To-do tab

Workaround:

Unknown

Platforms:

  • [x] Android: App
  • [ ] Android: mWeb Chrome
  • [x] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [ ] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/48bd50d2-0f59-4c08-8120-7da0806b9be0

View all open jobs on GitHub

Applause Internal Information Exported by: Julia Ponikarchuk Bug ID: 7272355

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @neerajbachani

applause-bot[bot] avatar Sep 29 '26 10:09 applause-bot[bot]

While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/989af41ee106a3a5e8a3dee7df03d80d17f3a3543e1a0fc712938514b32befde

applause-bot[bot] avatar Sep 29 '26 10:09 applause-bot[bot]

Proposal

What is the root cause of that problem?

The regression came from Fix: keep the To-do row when only an older sibling expense report is fully held (merged 2026-09-21, production 9.4.91-3). That PR moved the all-held check into candidate selection. For a chat whose only outstanding report is fully held, the fallback check now looks at the wrong report.

For User B (the approver), step by step:

  1. getIOUReportActionWithBadge skips the held report, because getBadgeFromIOUReport returns no badge when all expenses are held and B did not place the hold (ReportWorkflow.ts:339-343, :451-453). No other candidate exists, so no action is returned.
  2. getReasonAndReportActionThatRequiresAttention then falls back to the chat's own iouReportID (ReportUtils.ts:4627).
  3. Submitting a report clears that field on the chat (iouReportID: null, ReportWorkflow.ts:1500). So the fallback loads no transactions, and hasOnlyHeldExpenses([]) returns false (ReportUtils.ts:11878-11880).
  4. The fallback held-expense exclusion is therefore false (ReportUtils.ts:4636). hasOutstandingChildRequest: true alone makes hasValidIOUAction true (:4642-4645). The chat is returned as HAS_CHILD_REPORT_AWAITING_ACTION with no badge action (:4689-4694). This shows as a green dot in the To-dos tab, which matches the video.

Before that PR, the held report won selection, so iouReportID came from its preview and the old exclusion removed the chat correctly.

What changes do you think we should make in order to solve the problem?

Have getIOUReportActionWithBadge also return the ID of the first report it skipped because all its expenses are held. In getReasonAndReportActionThatRequiresAttention, use that ID before falling back to optionOrReport.iouReportID. The existing fallback exclusion then runs on the held report and removes the chat from To-dos. When a still-actionable sibling exists, it wins selection as before, so the sibling fix from that PR is kept.

Add a unit test that seeds a report preview for the single held report and leaves iouReportID unset on the chat. The existing tests set iouReportID on the chat (ReportUtilsTest.ts:4249-4255), which doesn't match the real state after submitting, so they miss this case.

What alternative solutions did you explore? (Optional)

  • Stop clearing iouReportID on submit. This touches the server contract and other readers of that field.
  • Run the held check across every report preview in the chat when nothing is selected. This works too, but it repeats the selection loop.
Scope and what's not verified
  • The Inbox To-dos tab uses the LHN filter (requiresAttention || hasErrorsOtherThanFailedReceipt in SidebarUtils.ts:997-1024), not Search.
  • Holding re-queues the parent chat for recompute of reportAttributes, so stale derived data is not the cause.
  • Not verified live. This comes from reading the code. I didn't run the two-account repro. I also assumed B's Onyx has the report preview and the transaction's hold data (pushed while B is signed in), and that the server keeps hasOutstandingChildRequest: true after a hold. If B's Onyx lacked the preview, the fix would need to come from the server's hasOutstandingChildRequest instead.
  • Separate, older gap: when the approver is not a member of the workspace chat, the assignee path for expense reports (ReportUtils.ts:4647-4664) has no held check. That would not cause this repro, where B is an admin.

Related: [Due for payment 2026-09-30] To-do-To-do becomes empty for Admin when Employee held the first report. Its fix is the PR that caused this regression.


Next Steps for Contributor+ team: To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/102525) to create a draft PR. To refine: @MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.


view run

MelvinBot avatar Sep 29 '26 11:09 MelvinBot

Triggered auto assignment to Contributor-plus team member for initial proposal review - @QichenZhu (External)

melvin-bot[bot] avatar Sep 29 '26 11:09 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022104889455672592391

melvin-bot[bot] avatar Sep 29 '26 11:09 melvin-bot[bot]

Proposal

Please re-state the problem that we are trying to solve in this issue.

In the To-do tab, an expense report that was held by the employee still appears as a pending item with a green dot for the approver/admin, even though all its expenses are on hold and cannot be acted upon.

What is the root cause of that problem?

This is a regression introduced in PR #100784 (Fix: keep the To-do row when only an older sibling expense report is fully held).

  1. In ReportWorkflow.ts, getBadgeFromIOUReport checks isReportExcludedForHeldExpenses. When all expenses in the child report are held by the employee, it returns undefined (no action badge).
  2. Consequently, in getReasonAndReportActionThatRequiresAttention, iouReportActionToApproveOrPay is undefined.
  3. The function then attempts a fallback:
    const iouReportID = getIOUReportIDFromReportActionPreview(iouReportActionToApproveOrPay) ?? optionOrReport.iouReportID;
    
  4. However, when an expense report is submitted, optionOrReport.iouReportID on the parent chat report is set to null (ReportWorkflow.ts:1500).
  5. Because iouReportActionToApproveOrPay is undefined and optionOrReport.iouReportID is null, iouReportID evaluates to null/undefined.
  6. As a result:
    • getReportTransactions(iouReportID) returns an empty array [].
    • isReportExcludedForHeldExpenses(null, [], ...) evaluates to false.
    • isFallbackReportExcludedForHeldExpenses becomes false.
  7. Because optionOrReport.hasOutstandingChildRequest is still true, hasValidIOUAction evaluates to true, and the chat report is incorrectly flagged as HAS_CHILD_REPORT_AWAITING_ACTION. It displays in the To-do tab with a green dot despite being fully held.

What changes do you think we should make in order to solve the problem?

In src/libs/ReportUtils.ts inside getReasonAndReportActionThatRequiresAttention: When iouReportActionToApproveOrPay is undefined, we need to properly resolve the child expense report ID from the chat's report previews rather than only falling back to optionOrReport.iouReportID (which is null once submitted).

Specifically:

  1. When optionOrReport.iouReportID is falsy and iouReportActionToApproveOrPay is undefined, extract the latest child report ID from the chat's reportActions (e.g., via report preview actions in reportActions). Or, have getIOUReportActionWithBadge track the child report ID of any preview that was excluded specifically because all its expenses are on hold (skippedHeldReportID), and use that ID when evaluating isFallbackReportExcludedForHeldExpenses.
  2. When the held report ID is resolved, getReportTransactions(heldReportID) retrieves the actual held transactions, isReportExcludedForHeldExpenses evaluates to true, and isFallbackReportExcludedForHeldExpenses correctly suppresses the chat report from the To-do list.

What alternative solutions did you explore? (Optional)

Stop clearing iouReportID to null on the chat report when submitting an expense report. However, optionOrReport.iouReportID is part of Onyx contracts across multiple consumers, so resolving the fallback child report ID from the preview action in getReasonAndReportActionThatRequiresAttention is much safer and contained.

bonnhatnguyen avatar Sep 29 '26 14:09 bonnhatnguyen

@bonnhatnguyen before the Help Wanted label is added, you are welcome to comment on issues, just don't post proposals.

QichenZhu avatar Sep 30 '26 13:09 QichenZhu

I don't quite agree with MelvinBot's solution since it's a band-aid. Let's look for a root solution.

QichenZhu avatar Sep 30 '26 13:09 QichenZhu

:sos: C+ Help Wanted

QichenZhu avatar Sep 30 '26 13:09 QichenZhu

🚨 Edited by proposal-police: This proposal was edited at 2026-10-01 07:50:47 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

After the employee submits a single-expense report and holds it, the approver still sees the workspace chat in the Inbox To-dos tab with a green dot. An all-held report isn't a to-do for the approver.

What is the root cause of that problem?

Whether the chat is a to-do comes down to hasValidIOUAction. It has two inputs joined by ||:

https://github.com/Expensify/App/blob/e5564c4dc4545c8e1c682cde8e47b423b83db032/src/libs/ReportUtils.ts#L4663-L4667

  1. iouReportActionToApproveOrPay is the client's answer. getIOUReportActionWithBadge checks every child report of the chat and applies the hold rule to each one, so here it correctly finds nothing to do
  2. hasOutstandingChildRequest is the server's answer. The server sets it on submit and nothing updates it on hold. Hold.ts never writes it, and the rule that an all-held report isn't a to-do exists only on the client

The root cause is that ||. Even when the client has checked every child report and found nothing actionable, the server flag still overrides it. That flag doesn't know about client-side rules like holds, so it's stale whenever one of them applies. In this repro the client finds no to-do and hasOutstandingChildRequest: true puts the chat back anyway.

The iouReportID lookup and isFallbackReportExcludedForHeldExpenses aren't the cause. They're a patch on top of it. They try to cancel the stale flag by re-checking holds on one guessed report:

https://github.com/Expensify/App/blob/e5564c4dc4545c8e1c682cde8e47b423b83db032/src/libs/ReportUtils.ts#L4648-L4658

That can't reach a submitted report, because submit clears the chat's iouReportID:

https://github.com/Expensify/App/blob/e5564c4dc4545c8e1c682cde8e47b423b83db032/src/libs/actions/IOU/ReportWorkflow.ts#L1499-L1500

Before #100784 the patch only worked because the held report happened to win the walk.

The pending card guard on L4650-4651 has the same problem. It also uses the guessed iouReportID, so it never fires for a submitted report. A submitted report with only a pending Expensify Card expense shows the same bare green dot for the approver on main today. That's how we know the bug is the stale flag winning, not something specific to holds.

What changes do you think we should make in order to solve the problem?

Only trust the server flag for child reports the client can't check itself.

  1. In getIOUReportActionWithBadge, also return whether every child report preview in the chat was actually evaluated. A preview counts as unevaluated when its report isn't in Onyx yet (and it isn't reimbursed). If there are no previews at all, nothing was evaluated:
let hasEvaluatedChildReport = false;
let hasUnevaluatedChildReport = false;
...
if (!iouReport) {
    if (chatReport?.hasOutstandingChildRequest && canPayIOUFromReportAction(action, chatReport, currentUserAccountID)) {
        ...
    } else if (action.childStatusNum !== CONST.REPORT.STATUS_NUM.REIMBURSED) {
        hasUnevaluatedChildReport = true;
    }
    continue;
}

hasEvaluatedChildReport = true;
...
return {reportAction: earliestAction, actionBadge, areChildReportsEvaluated: hasEvaluatedChildReport && !hasUnevaluatedChildReport};
  1. In getReasonAndReportActionThatRequiresAttention, treat the flag as stale when the client has checked everything. It sits next to the existing trip room staleness check:
const {reportAction: iouReportActionToApproveOrPay, actionBadge, areChildReportsEvaluated} = getIOUReportActionWithBadge(...);
...
// The server flag doesn't know about holds, so it only counts when some child report couldn't be checked locally.
const hasStaleChildRequest = (isTripRoom(optionOrReport) && (optionOrReport.transactionCount ?? 0) === 0) || areChildReportsEvaluated;

So the client decides when it has the data, and the server flag only fills the gap when it doesn't (right after login, previews not loaded yet, p2p IOU fallback). The hold rule stays in getBadgeFromIOUReport only, so we don't add a second copy of it.

What stays the same:

  • An approvable sibling still gets the badge (#100784 / #100365), because it still wins the walk
  • If the approver placed the hold, the report still gets its Approve badge from the walk, so the row stays as #96178 intended
  • If a sibling preview's report isn't loaded yet, the flag is still trusted, so we don't hide a to-do we can't verify
  • The existing iouReportID veto is left alone. It now only matters when the chat has no previews loaded

Tests in ReportUtilsTest, using the real post-submit shape (chat iouReportID unset, a REPORT_PREVIEW for the child report):

  • another user placed the hold -> no attention (fails on main, Expected: false, Received: true)
  • held report + an older paid report in the same chat -> no attention (fails on main)
  • submitted report with only a pending card expense -> no attention (fails on main)
  • approver placed the hold on a Collect workspace -> still requires attention
  • held report + a sibling preview whose report isn't loaded -> still requires attention

The new tests pass, and the related suites (ReportUtilsTest, SidebarUtilsTest, useTodoCountsTest, reportAttributesTest, LHNItemsPresence, ReportWorkflowTest and others, 2600+ tests) pass. Typecheck and ESLint are clean.

Branch: https://github.com/Expensify/App/compare/main...dilshodmackbook-sketch:App:poc/102525-stale-outstanding-flag

What alternative solutions did you explore? (Optional)

  • Return the held report ID, or a held-only boolean, from the walk and feed it into isFallbackReportExcludedForHeldExpenses. This was my earlier version, and most proposals here do the same. It fixes the hold repro, but it only patches over the stale flag for one rule. The pending card case above still breaks, and every future client-only rule would need its own channel out of the walk.
  • Have the backend recompute hasOutstandingChildRequest on hold/unhold. This is the cleanest long-term fix and worth raising internally. But the flag is per viewer, and the "placed the hold yourself" exception would have to be copied to the server. The client would still need this change for data that's already in Onyx.
  • Make iouReportID point at the submitted report. It's the chat's "where do new expenses go" pointer and has many readers, so reusing it for approval state would break money request flows.

David-2002065 avatar Sep 30 '26 13:09 David-2002065

🚨 Edited by proposal-police: This proposal was edited at 2026-10-01 13:31:15 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Approver still sees the employee's workspace chat in To-dos with a green dot after the employee submits a single-expense report and holds it. Only the employee can unhold, so there is nothing for the approver to do.

What is the root cause of that problem?

Two things meet here.

  1. The workspace chat's hasOutstandingChildRequest goes stale on hold. I logged the approver's decrypted Pusher payloads during the exact repro steps. After submit the approver gets report_<chatID> with hasOutstandingChildRequest: true. After the hold the payload carries the transaction hold, the expense report and the transaction thread, but the chat only gets reportActions_<chatID>, never report_<chatID>. So the flag stays true until the approver opens the chat and OpenReport brings false. The false values in the hold payload belong to the transaction thread and the expense report, not to the chat.

  2. The App already has a held check meant to cover this, and it stopped working. The selector walks every report preview and rejects the fully held report, but then drops that verdict with a bare continue:

https://github.com/Expensify/App/blob/589b5f867bd9916eedf90a6300732d0d6dcc1011/src/libs/actions/IOU/ReportWorkflow.ts#L448-L454

getReasonAndReportActionThatRequiresAttention then re-derives the same held rule on its own, finding the report through the chat's iouReportID. Submit sets that to null, so the check reads 0 transactions, returns false, and the stale flag alone keeps the chat in To-dos:

https://github.com/Expensify/App/blob/589b5f867bd9916eedf90a6300732d0d6dcc1011/src/libs/ReportUtils.ts#L4648-L4667

Before the held check moved into the selector, the held report still won selection, so its preview ID happened to reach the second check. That coupling is gone, and the second check has been blind since.

flowchart TD
    A["Employee holds the only report"] -->|"Pusher: hold yes, report_chat no"| B["chat flag stays true"]
    B --> C["selector rejects held report, drops the verdict"]
    C --> D["second check re-derives via chat iouReportID"]
    D -->|"null after submit, 0 transactions"| E["held exclusion = false"]
    E -->|"stale flag wins"| F["green dot in To-dos"]

What changes do you think we should make in order to solve the problem?

Make the selector the only owner of the held rule and delete the copy in getReasonAndReportActionThatRequiresAttention. The selector returns whether a held child is the reason nothing needs action (true only when no sibling won, so an approvable sibling still shows Approve). It also checks the chat's iouReportID when no preview is loaded, which keeps the open-report case the old check covered.

 // ReportWorkflow.ts, getIOUReportActionWithBadge
     reportAction: OnyxEntry<ReportAction>;
     actionBadge?: ValueOf<typeof CONST.REPORT.ACTION_BADGE>;
+    isExcludedForHeldExpenses: boolean;
 ...
         if (!badge) {
+            if (!hasChildExcludedForHeldExpenses) {
+                hasChildExcludedForHeldExpenses = isReportExcludedForHeldExpenses(iouReport, getReportTransactions(iouReport.reportID), iouReportActions, currentUserAccountID);
+            }
             continue;
         }
 ...
+    if (!earliestAction && !hasChildExcludedForHeldExpenses && chatReport?.iouReportID) {
+        const openReport = getReportOrDraftReport(chatReport.iouReportID, undefined, undefined, undefined, allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReport.iouReportID}`]);
+        const openReportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport.iouReportID}`];
+        hasChildExcludedForHeldExpenses = isReportExcludedForHeldExpenses(openReport, getReportTransactions(chatReport.iouReportID), openReportActions, currentUserAccountID);
+    }
-    return {reportAction: earliestAction, actionBadge};
+    return {reportAction: earliestAction, actionBadge, isExcludedForHeldExpenses: !earliestAction && hasChildExcludedForHeldExpenses};
 // ReportUtils.ts, getReasonAndReportActionThatRequiresAttention
-    const {reportAction: iouReportActionToApproveOrPay, actionBadge} = getIOUReportActionWithBadge(
+    const {reportAction: iouReportActionToApproveOrPay, actionBadge, isExcludedForHeldExpenses} = getIOUReportActionWithBadge(
 ...
-    const iouReport = reports ? reports[`${ONYXKEYS.COLLECTION.REPORT}${iouReportID}`] : getReportOrDraftReport(iouReportID);
-    const iouReportActions = allReportActionsParam?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`] ?? getAllReportActions(iouReportID);
-    const isFallbackReportExcludedForHeldExpenses = !iouReportActionToApproveOrPay && isReportExcludedForHeldExpenses(iouReport, transactions, iouReportActions, currentUserAccountID);
 ...
         !hasOnlyPendingTransactions &&
-        !isFallbackReportExcludedForHeldExpenses;
+        !isExcludedForHeldExpenses;

I verified it live with Pusher connected on the approver side. After the hold the chat flag was still a stale true, same as when the bug shows, but requiresAttention went to false and the row left To-dos right away, without opening the chat. The approver who placed the hold themselves keeps the row, and an approvable sibling still shows Approve.

Test: a chat whose held report is reachable only through its preview, with iouReportID unset (the real post-submit state). It fails on main (Received: true) and passes with the change. The existing held and sibling tests pass unchanged.

What alternative solutions did you explore? (Optional)

  • Return the held report's ID from the selector and feed it into the existing second check. That keeps the held rule running in two places that can drift apart again.
  • Have HoldRequest / UnHoldRequest push the recomputed chat flag to every participant. That fixes the stale value at its source and is worth doing as a follow-up, but the App still needs to handle a stale flag correctly.

mukhrr avatar Sep 30 '26 13:09 mukhrr

🚨 Edited by proposal-police: This proposal was edited at 2026-09-30 14:02:48 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

An employee submits a single-expense report and then puts that expense on hold. On the approver's side, the Inbox To-do tab still lists the report's workspace chat with a green dot, even though a fully-held report cannot move forward and there is nothing for the approver to do. The row should not appear in the To-do tab and should not carry the green "requires attention" indicator.

What is the root cause of that problem?

The To-do tab lists any report whose derived requiresAttention flag is true (getIsTodoReportForInboxTab in SidebarUtils). For the workspace chat, that flag is produced by getReasonAndReportActionThatRequiresAttention, where hasValidIOUAction is driven by the server-set hasOutstandingChildRequest === true on the chat β€” a flag the backend keeps set even while every expense on the child report is held:

https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/ReportUtils.ts#L4626-L4645

The app is supposed to suppress this client-side through the all-held exclusion, isReportExcludedForHeldExpenses:

https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/ReportUtils.ts#L4904-L4914

The problem is that every signal this exclusion reads lives in child-report data that the approver's client typically does not have, because the approver has not opened the report (which is exactly the repro precondition "don't click on user A's report"):

  1. The exclusion decides "all expenses are held" with hasOnlyHeldExpenses, which requires a non-empty, locally-loaded transaction list β€” for an empty array it returns false:

https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/ReportUtils.ts#L11875-L11880

  1. On the fallback path the held child is located through the chat's iouReportID pointer. When that pointer is missing on the approver's copy of the chat (or points to a report that isn't loaded), getReportTransactions is called with undefined and returns nothing, so the exclusion silently never fires.

  2. The badge-candidate path (getIOUReportActionWithBadge) drops the held preview because it yields no badge β€” but dropping the candidate only sends the code down the fallback path above, where hasOutstandingChildRequest alone resurrects the green dot:

https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/actions/IOU/ReportWorkflow.ts#L446-L459

The repro video confirms this signature: the chat row shows a bare green dot with no "Approve" chip, while every other actionable row in the list shows its action chip. That is exactly what this path produces, because the Approve badge itself (canApproveIOU) refuses to render without loaded transactions (reportTransactions.length > 0), while the green dot needs only the hasOutstandingChildRequest flag:

https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/actions/IOU/ReportWorkflow.ts#L199-L206

So the all-held exclusion fails open on the approver's client, and the held single-expense report's chat stays in the To-do tab with a green dot.

What changes do you think we should make in order to solve the problem?

Make the all-held exclusion work from data the approver's client actually has, instead of depending on locally-loaded transactions:

  1. In isReportExcludedForHeldExpenses, when the passed transaction list is empty but the child report object is available, detect the all-held state from the report's own server-computed money fields: the backend (and the app's own optimistic hold updates) maintain unheldTotal on the expense report whenever any hold exists, so a fully-held report has unheldTotal equal to zero while its total is non-zero. The existing transaction-based check stays in place when transactions are loaded, since it is more precise and also powers the "current user placed the hold" carve-out (didCurrentUserPlaceHoldOnReportExpense). Evidence that unheldTotal is the canonical held-state field maintained on hold/unhold:

https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/actions/IOU/Hold.ts#L139-L146

  1. In getReasonAndReportActionThatRequiresAttention, make the fallback path robust to a missing iouReportID pointer: have getIOUReportActionWithBadge also report whether it skipped a report-preview candidate because of the all-held exclusion, and when the chat's iouReportID does not resolve to a loaded child report, use that signal as the fallback exclusion instead of letting hasOutstandingChildRequest alone bring the green dot back. When the pointer does resolve, the check from point 1 runs against that report as before.

Together these keep the intended behavior of the existing exclusion: the person who placed the hold still sees the report in their To-do (their client has the hold data, and the carve-out still applies), and the sibling-report behavior (a chat stays in To-do when a different, actionable child exists) is unchanged because the exclusion continues to run per child report.

Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/102525-held-report-todo-green-dot?expand=1

What alternative solutions did you explore? (Optional)

  • Fixing it on the backend by clearing hasOutstandingChildRequest on the approver's copy of the chat while every expense is held. That would also resolve the symptom, but the app already owns this logic client-side (the exclusion exists precisely because the server keeps the flag set), and a front-end fix keeps the behavior consistent for optimistic/offline holds.
  • Filtering held reports only in getIsTodoReportForInboxTab (the To-do tab filter). Rejected: the green dot itself is wrong, not just the tab membership β€” the row would still show a green dot in the All tab, and the To-do count badge is computed from the same attribute, so the fix belongs where requiresAttention is derived.

wildan-m avatar Sep 30 '26 13:09 wildan-m

πŸ€– ProposalPoliceβ„’ is tracking duplicate proposals for this issue using an OpenAI Conversation. This comment stores that Conversation's ID and can be safely ignored.

github-actions[bot] avatar Sep 30 '26 13:09 github-actions[bot]

Withdrawn. I ran the fix below in unit tests against the commit my links point to, and it does not hold up. It clears the To-do in the reported case, a chat whose only report is fully held by the employee. But if the same chat also has an older reimbursed report, the chat stays in the approver's To-do with a green dot. The reimbursed report doesn't count as fully held (its expense isn't on hold, and if its expenses aren't loaded an empty list doesn't count either), so the AND over the chat's loaded reports comes out false. It also takes the chat out of To-do, where main keeps it, when the chat has another submitted report waiting on the approver that isn't loaded yet, because the AND skips reports that aren't loaded. So the "widening, not a removal" argument below only holds when every report in the chat is loaded. The original is left below for reference.


Proposal

What is the root cause of that problem?

One detail that gets missed here: the "no badge" outcome in the selection loop is not a held-expenses signal. getBadgeFromIOUReport() returns undefined on many paths unrelated to holds (not the payer, not an approver, nothing submittable, RTER violations) β€” the hold exclusion is just its first early return:

https://github.com/Expensify/App/blob/9a19e900d41998c0b03732281a882ccf1ea66e9c/src/libs/actions/IOU/ReportWorkflow.ts#L339-L343

So the fix cannot be "remember the first preview that produced no badge and treat the chat as held", and it cannot be "remember the first report the hold exclusion rejected and use its ID as the fallback" either: a chat can own a fully-held report and a second outstanding report that is merely not badge-eligible for this viewer right now, and reusing the held sibling's ID would silently drop a legitimate To-do row. The exclusion has to be an aggregate over every resolvable preview child, not a single remembered ID. Gating the new path on chatReport.iouReportID being absent is fragile too: it can be non-null and point at a stale child.

Mechanism, for User B after A holds the single expense. The Inbox To-do tab is a pure filter over the LHN set β€” a report is in when requiresAttention (GBR) or an RBR is set:

https://github.com/Expensify/App/blob/9a19e900d41998c0b03732281a882ccf1ea66e9c/src/libs/SidebarUtils.ts#L997-L1000

requiresAttention comes from getReasonAndReportActionThatRequiresAttention(); the LHN row is the workspace chat and the branch that fires is HAS_CHILD_REPORT_AWAITING_ACTION:

https://github.com/Expensify/App/blob/9a19e900d41998c0b03732281a882ccf1ea66e9c/src/libs/ReportUtils.ts#L4626-L4645

  1. getIOUReportActionWithBadge() walks the chat's REPORTPREVIEW actions. The all-held child yields no badge, so it is continued and earliestAction stays undefined β€” the "this report is fully held" fact dies inside the loop:

https://github.com/Expensify/App/blob/9a19e900d41998c0b03732281a882ccf1ea66e9c/src/libs/actions/IOU/ReportWorkflow.ts#L446-L459

  1. Line 4627 falls back to optionOrReport.iouReportID to re-resolve the child. On a submitted report that field is null β€” submitReport nulls it on the policy expense chat:

https://github.com/Expensify/App/blob/9a19e900d41998c0b03732281a882ccf1ea66e9c/src/libs/actions/IOU/ReportWorkflow.ts#L1490-L1502

  1. With no ID, transactions is [] and iouReport is undefined, so isReportExcludedForHeldExpenses short-circuits on hasOnlyHeldExpenses([]) β€” false for an empty array β€” and the guard returns false:

https://github.com/Expensify/App/blob/9a19e900d41998c0b03732281a882ccf1ea66e9c/src/libs/ReportUtils.ts#L4907-L4913

https://github.com/Expensify/App/blob/9a19e900d41998c0b03732281a882ccf1ea66e9c/src/libs/ReportUtils.ts#L11878-L11880

  1. hasValidIOUAction therefore collapses to optionOrReport.hasOutstandingChildRequest === true, the chat-level flag written at submit time that putOnHold never clears (zero hasOutstandingChildRequest writes in src/libs/actions/IOU/Hold.ts). Green dot β†’ row in To-do.

This predicts the exact reported shape β€” green dot, but no green Approve badge: actionBadge is correctly undefined from step 1; only the dot survives. It also explains why Search's to-do buckets are fine: they re-check all-held per report, with the carve-out for the user who placed the hold:

https://github.com/Expensify/App/blob/9a19e900d41998c0b03732281a882ccf1ea66e9c/src/libs/TodosUtils.ts#L148-L149

What changes do you think we should make in order to solve the problem?

Carry the exclusion out of the loop instead of re-deriving it from chatReport.iouReportID.

In getIOUReportActionWithBadge() (src/libs/actions/IOU/ReportWorkflow.ts), compute the exclusion per preview child and AND it across all of them (isReportExcludedForHeldExpenses/getReportTransactions are already imported):

// Stays undefined until a preview child resolves, so a chat whose children aren't loaded keeps today's behavior.
let areAllChildReportsHeld: boolean | undefined;
...
const iouReportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.reportID}`];
const isExcluded = isReportExcludedForHeldExpenses(iouReport, getReportTransactions(iouReport.reportID), iouReportActions, currentUserAccountID);
areAllChildReportsHeld = (areAllChildReportsHeld ?? true) && isExcluded;
const badge = getBadgeFromIOUReport(...);
...
return {reportAction: earliestAction, actionBadge, areAllChildReportsHeld: areAllChildReportsHeld === true};

Then widen the guard in getReasonAndReportActionThatRequiresAttention() (src/libs/ReportUtils.ts:4615-4636); the existing call stays as the fallback for p2p/IOU chats whose preview child isn't loaded:

const {reportAction: iouReportActionToApproveOrPay, actionBadge, areAllChildReportsHeld} = getIOUReportActionWithBadge(...);
...
const isFallbackReportExcludedForHeldExpenses =
    !iouReportActionToApproveOrPay &&
    (areAllChildReportsHeld || isReportExcludedForHeldExpenses(iouReport, transactions, iouReportActions, currentUserAccountID));

This is a widening, not a removal: areAllChildReportsHeld can only be true when every resolvable child was held-excluded, so nothing that produces a badge changes and the sibling case stays fixed. It also preserves the deliberate carve-out β€” the user who placed the hold keeps the report, since the exclusion returns false for them.

Regression test in tests/unit/ReportUtilsTest.ts: policy expense chat with hasOutstandingChildRequest: true and iouReportID: null, one submitted child holding a transaction whose comment.hold action was created by another accountID; assert the reason is null for the approver and still HAS_CHILD_REPORT_AWAITING_ACTION for the hold creator. Existing cases set iouReportID on the chat, which isn't the post-submit state, so they can't catch this.

trasnake87 avatar Sep 30 '26 13:09 trasnake87

🚨 Edited by proposal-police: This proposal was edited at 2026-10-02 18:42:11 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

When an employee submits a single-expense report and then places that expense on hold, the approver's Inbox "To-do" tab should stop listing that report (and stop showing the green "requires attention" dot / Approve badge), because its expenses are on hold for the employee to resolve. Instead, the report keeps showing up in the approver's To-do tab with a green dot.

What is the root cause of that problem?

The "To-do" tab renders reports whose requiresAttention flag is true: https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/SidebarUtils.ts#L997-L999

requiresAttention is computed per report (including workspace chat reports) by generateReportAttributes, which delegates to getReasonAndReportActionThatRequiresAttention. That function first tries to find an approvable/payable REPORT_PREVIEW action via getIOUReportActionWithBadge. That helper already excludes all-held reports correctly (it calls isReportExcludedForHeldExpenses per candidate IOU report and skips it when the badge comes back empty): https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/actions/IOU/ReportWorkflow.ts#L340-L343 So for our held single-expense report, iouReportActionToApproveOrPay correctly comes back undefined β€” the "correct" answer was already computed and then thrown away.

The caller then tries to redo the held-expense check itself as a "fallback", but derives the IOU report ID from the wrong place: https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/ReportUtils.ts#L4626-L4645

const iouReportID = getIOUReportIDFromReportActionPreview(iouReportActionToApproveOrPay) ?? optionOrReport.iouReportID;

Since iouReportActionToApproveOrPay is undefined, this falls back to optionOrReport.iouReportID (optionOrReport here is the parent workspace chat). That field is not a reliable pointer to the submitted report represented by the excluded preview. In my local approver-side reproduction it was missing, even though the submitted expense report, its transaction and its hold were already loaded.

With no fallback report ID, getReportTransactions(iouReportID) returns [], and isReportExcludedForHeldExpenses returns false because an empty transaction list does not satisfy hasOnlyHeldExpenses: https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/ReportUtils.ts#L4909-L4914

With isFallbackReportExcludedForHeldExpenses now false, hasValidIOUAction (ReportUtils.ts#L4642-L4645) falls back to the raw hasOutstandingChildRequest boolean on the parent chat. In the reproduced failure, that parent flag remained true after the hold; the derived reason was hasChildReportAwaitingAction, with no selected preview and no actionBadge. This produces the bare green dot and keeps the chat in To-do even though the preview scan correctly excluded the held report.

The report ID matters when interpreting the review's hasOutstandingChildRequest: false payload. I captured hold pushes updating the child expense report to false without updating the parent workspace chat's flag. Those are different Onyx entries. Opening the parent chat afterward refreshed its flag to false and cleared its attention reason. The frontend bug is that the held-exclusion result from the actual child preview is lost, allowing the parent's fallback flag to restore attention before that refresh.

What changes do you think we should make in order to solve the problem?

The fix is to preserve the held-expense verdict from the actual preview candidates, instead of relying solely on chatReport.iouReportID after no badge is found.

Change getIOUReportActionWithBadge (and the getBadgeFromIOUReport call it makes) in https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/actions/IOU/ReportWorkflow.ts#L403-L462 so that when a REPORT_PREVIEW candidate is skipped specifically because isReportExcludedForHeldExpenses returned true for it (line 341-343 inside getBadgeFromIOUReport), that outcome is tracked and returned to the caller (e.g. add an isExcludedForHeldExpenses: boolean field to the object returned by getIOUReportActionWithBadge). This must represent an all-held result for the relevant outstanding children, not merely "one held preview was found": keep scanning so an actionable sibling can still win, and preserve the existing fallback when a potentially outstanding child or its transaction/hold data is not loaded well enough to establish the exclusion. Deleted, settled or unrelated draft previews must not be mistaken for outstanding candidates.

Then in getReasonAndReportActionThatRequiresAttention https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/ReportUtils.ts#L4626-L4645 extend the existing fallback check with the exclusion result from the actual previews:

const {reportAction: iouReportActionToApproveOrPay, actionBadge, isExcludedForHeldExpenses} = getIOUReportActionWithBadge(...);
...
const isFallbackReportExcludedForHeldExpenses =
    !iouReportActionToApproveOrPay &&
    (isExcludedForHeldExpenses ||
        isReportExcludedForHeldExpenses(iouReport, transactions, iouReportActions, currentUserAccountID));

This lets the known held child suppress the fallback even when optionOrReport.iouReportID is missing or points elsewhere, while retaining the existing check for chats whose child is available only through that field. The rest of hasValidIOUAction's logic (the hasOutstandingChildRequest fallback, hasStaleChildRequest, hasOnlyPendingTransactions) can stay as-is, since the fix only corrects the exclusion signal that was being computed from the wrong source.

This reuses the exclusion logic that already exists (isReportExcludedForHeldExpenses, didCurrentUserPlaceHoldOnReportExpense) rather than introducing a new helper, and mirrors the pattern already used correctly in src/libs/TodosUtils.ts (which threads allExpensesHeld/currentUserPlacedHold through explicitly instead of re-deriving them from a report field).

Verify the regression with the approver left on an unrelated chat: submit and hold the employee expense, assert that the parent chat loses both its attention dot and its To-do entry without opening it, then unhold and assert that the Approve badge returns. Cover a missing/unrelated fallback ID, an actionable sibling, incomplete child data, and a hold placed by the current user.

Demo and test branch

Test branch: test/102525-held-report (tested commit).

App recording: Employee view on the left; approver's Inbox To-dos on the right. The recording shows More β†’ Hold, entering a reason, the held report disappearing from the approver's To-dos, and the Approve badge returning after Remove hold. The approver stays on an unrelated chat without opening the affected chat or refreshing during the hold/unhold flow.

https://github.com/user-attachments/assets/e6683242-bcc8-4705-9151-6fe692451b93

Validation: All 1,566 tests passed across ReportUtilsTest, OnyxDerivedTest, and ReportWorkflowTest. Full typecheck, lint on changed files, formatting, and spelling checks passed. Browser verification was on the local web build.

abbasifaizan70 avatar Sep 30 '26 14:09 abbasifaizan70

Proposal

What is the root cause of that problem?

When the employee holds the only expense on a submitted report, the approver still gets that workspace chat in the Inbox To-do tab as a green attention dot with no Approve chip.

getIOUReportActionWithBadge walks the chat's report previews and skips any preview whose badge is missing. A fully held report that the current user did not hold never gets a badge, so that preview is thrown away and nothing is returned:

https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/actions/IOU/ReportWorkflow.ts#L339-L343

https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/actions/IOU/ReportWorkflow.ts#L448-L453

getReasonAndReportActionThatRequiresAttention then has to guess the child report from that missing action or from the chat's iouReportID:

https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/ReportUtils.ts#L4614-L4629

Submit already cleared iouReportID on the chat, so getReportTransactions loads no rows and hasOnlyHeldExpenses([]) is false. The held-expense exclusion therefore does not run:

https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/actions/IOU/ReportWorkflow.ts#L1490-L1501

https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/ReportUtils.ts#L11878-L11880

hasOutstandingChildRequest is still true, which alone sets hasValidIOUAction and emits HAS_CHILD_REPORT_AWAITING_ACTION with no badge action:

https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/ReportUtils.ts#L4631-L4645

https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/ReportUtils.ts#L4689-L4694

The skip is useful when a later sibling still has Approve or Pay. When the held report is the only child, it also removes the only preview the fallback exclusion can read. The chat-level iouReportID is not a substitute after submit.

What changes do you think we should make in order to solve the problem?

  1. In getIOUReportActionWithBadge, keep the first preview skipped because isReportExcludedForHeldExpenses made the badge undefined. Do not change how a real badge is chosen.

https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/actions/IOU/ReportWorkflow.ts#L446-L459

if (!actionBadge) {
    if (!heldReportAction && isReportExcludedForHeldExpenses(iouReport, reportTransactions)) {
        heldReportAction = reportAction;
    }
    continue;
}
  1. After the loop, if no badged preview won, return that held preview as reportAction and leave actionBadge unset. If a later preview did win, return that one unchanged.
if (earliestAction) {
    return {reportAction: earliestAction, actionBadge};
}
return {reportAction: heldReportAction, actionBadge: undefined};

A payable sibling still wins, which keeps the older-sibling behavior. When the held report is the only child, getIOUReportIDFromReportActionPreview in getReasonAndReportActionThatRequiresAttention reads that preview again, isFallbackReportExcludedForHeldExpenses runs on the held transactions, and the chat leaves To-dos. No new return field and no change to hasValidIOUAction.

https://github.com/Expensify/App/blob/e6251461d2a8caf578487e86d3d851bd23b97ee8/src/libs/ReportUtils.ts#L4614-L4629

What alternative solutions did you explore? (Optional)

Add a parallel excludedHeldReportID on the badge helper's return value and thread it into the fallback id. That works, but it widens the helper's contract when the existing reportAction slot already carries the preview the fallback needs.

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

samranahm avatar Sep 30 '26 14:09 samranahm

Proposal updated β€” added compare branch with implementation.

wildan-m avatar Sep 30 '26 14:09 wildan-m

🚨 Edited by proposal-police: This proposal was edited at 2026-10-01 08:47:31 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

An employee submits one expense on a workspace chat and then puts that expense on hold. The approver still sees that chat in Inbox To-do with a green dot and no Approve chip. Only the employee can take the hold off, so the chat should not be in To-do.

What is the root cause of that problem?

The To-do tab lists any report whose requiresAttention is true:

https://github.com/Expensify/App/blob/e5564c4dc4545c8e1c682cde8e47b423b83db032/src/libs/SidebarUtils.ts#L997-L1000

For the workspace chat, that flag comes from getReasonAndReportActionThatRequiresAttention. I reproduced this on a local web build against dev, as the approver, and read the values at the moment of the hold. The chat was 5007146800239778. The submitted expense was 3907222169505318. After submit, the chat's iouReportID was not null and was not that expense. It was 5967365308405346, the next empty open draft.

Before the hold, the walk selected the submitted child and the badge was approve. hasOutstandingChildRequest was true. That is correct.

The hold update reached the approver. The submitted report stayed statusNum: 1 with unheldTotal: 0. The walk applied the held exclusion and dropped the child:

https://github.com/Expensify/App/blob/e5564c4dc4545c8e1c682cde8e47b423b83db032/src/libs/actions/IOU/ReportWorkflow.ts#L339-L343

On the approver, that call returned no badge. The measured inputs were one transaction, onHold: true, isOpenExpenseReport: false, and currentUserPlacedHold: false, so excluded was true. The loop treats that the same as every other missing badge and returns no action:

https://github.com/Expensify/App/blob/e5564c4dc4545c8e1c682cde8e47b423b83db032/src/libs/actions/IOU/ReportWorkflow.ts#L448-L461

The veto then has to pick a report of its own. With no selected preview, it uses the chat's iouReportID:

https://github.com/Expensify/App/blob/e5564c4dc4545c8e1c682cde8e47b423b83db032/src/libs/ReportUtils.ts#L4648-L4667

Measured on the approver immediately after the hold, before opening the chat again:

  • selectedPreviewChildReportID: null
  • chatIouReportID and fallbackIouReportID: 5967365308405346 (the empty open draft)
  • transactionCount: 0
  • isFallbackReportExcludedForHeldExpenses: false
  • hasOutstandingChildRequest: true
  • hasValidIOUAction: true
  • actionBadge: null

An empty transaction list is not "all held":

https://github.com/Expensify/App/blob/e5564c4dc4545c8e1c682cde8e47b423b83db032/src/libs/ReportUtils.ts#L11919-L11921

So the exclusion, which is only true when every transaction is held, never sees the submitted report. The outstanding flag alone keeps the green dot, with no Approve chip.

The same session rules out the other explanations. The held transaction was already on the approver (onHold: true, excluded: true on 3907222169505318). The chat was recomputed in that same update. The approver was not recorded as the hold creator (currentUserPlacedHold: false). A later OpenReport of the chat returned hasOutstandingChildRequest: false, which is why opening the chat makes the dot disappear. The wrong decision is the veto above, while that flag is still true.

PR #100784 stays. Before it, the held report could win selection, so this fallback read that preview's linkedReportID and the exclusion ran on the held transactions. That PR correctly stopped the held report from winning, so an approvable sibling is no longer hidden. It left this fallback on chat.iouReportID, which names the open draft.

What changes do you think we should make in order to solve the problem?

Keep the walk's held result instead of throwing it away, and use that result in the veto. Do not replace optionOrReport.iouReportID. That id is the open draft, and it still feeds hasOnlyPendingTransactions.

In getIOUReportActionWithBadge (src/libs/actions/IOU/ReportWorkflow.ts), declare hasHeldReport and hasUnresolvedOutstandingReport as false before the preview loop:

             if (chatReport?.hasOutstandingChildRequest && canPayIOUFromReportAction(action, chatReport, currentUserAccountID)) {
                 if (!earliestAction || isOlderReportAction(action, earliestAction)) {
                     earliestAction = action;
                     actionBadge = CONST.REPORT.ACTION_BADGE.PAY;
                 }
+            } else if (action.childStatusNum !== CONST.REPORT.STATUS_NUM.REIMBURSED && action.childStatusNum !== CONST.REPORT.STATUS_NUM.CLOSED) {
+                hasUnresolvedOutstandingReport = true;
             }
         if (!badge) {
+            hasHeldReport ||= isReportExcludedForHeldExpenses(iouReport, getReportTransactions(iouReport.reportID), iouReportActions, currentUserAccountID);
             continue;
         }
-    return {reportAction: earliestAction, actionBadge};
+    return {reportAction: earliestAction, actionBadge, isBlockedOnlyByHeldReports: !earliestAction && hasHeldReport && !hasUnresolvedOutstandingReport};

In getReasonAndReportActionThatRequiresAttention (src/libs/ReportUtils.ts):

-    const {reportAction: iouReportActionToApproveOrPay, actionBadge} = getIOUReportActionWithBadge(
+    const {reportAction: iouReportActionToApproveOrPay, actionBadge, isBlockedOnlyByHeldReports} = getIOUReportActionWithBadge(
-    const isFallbackReportExcludedForHeldExpenses = !iouReportActionToApproveOrPay && isReportExcludedForHeldExpenses(iouReport, transactions, iouReportActions, currentUserAccountID);
+    const isFallbackReportExcludedForHeldExpenses =
+        !iouReportActionToApproveOrPay && (isBlockedOnlyByHeldReports || isReportExcludedForHeldExpenses(iouReport, transactions, iouReportActions, currentUserAccountID));

isBlockedOnlyByHeldReports is true only when nothing was selected, at least one loaded child was held-excluded, and no preview was left unloaded unless it is reimbursed or closed. The existing term stays for an open or p2p report whose iouReportID really is the child and whose preview is not loaded yet.

On the captured hold: the submitted child sets hasHeldReport, the empty open draft is loaded so it is not unresolved, no badge was selected, the flag is true, and hasValidIOUAction becomes false. After the hold was removed, that same child returned badge: "approve", so earliestAction is set and the flag is not read. An approvable sibling still wins selection, so the behavior from #100784 stays. The person who placed the hold still gets a badge, because isReportExcludedForHeldExpenses is false for them:

https://github.com/Expensify/App/blob/e5564c4dc4545c8e1c682cde8e47b423b83db032/src/libs/ReportUtils.ts#L4952-L4957

submitReport, hasOutstandingChildRequest, and the assignee path stay as they are. To-do membership, the To-do count, and the green dot all read requiresAttention, so this one change covers all three.

What alternative solutions did you explore? (Optional)

  • Remember the held report's id and use it as the fallback iouReportID. This fixes the single-child case and was rejected as a band-aid. It also sends transactions at the held report, so hasOnlyPendingTransactions judges the wrong child. A held report plus an outstanding sibling that is not loaded yet would be hidden, which is the bug #100784 fixed.
  • AND the held check across every preview. Fails on this account. The empty open draft 5967365308405346 has transactionCount: 0, so it is not all-held, and the AND would never fire.
  • Revert #100784. Brings back #100365.
  • Clear iouReportID or point it at the submitted report. On this account it already pointed at the next open draft, which is what that field is for.
  • Treat unheldTotal === 0 as all-held. The submitted report did have unheldTotal: 0, but that drops the carve-out for the person who placed the hold.
  • Wait for the server to clear hasOutstandingChildRequest. The next OpenReport of the chat did return false, which is why opening the chat hides the dot. The hold pusher did not include that update, and the client already owns this veto so an offline hold stays consistent.

What specific scenarios should we cover in automated tests?

Add these under when the outstanding child expense is all on hold in tests/unit/ReportUtilsTest.ts. Seed a REPORT_PREVIEW for the submitted child and set the chat's iouReportID to a different open draft that has no transactions, which is the shape measured above.

  • One submitted, all-held child, hold placed by the submitter, hasOutstandingChildRequest: true: the approver does not require attention.
  • The same chat, with the approver as the hold creator: still requires attention, and the badge is APPROVE.
  • A held submitted child plus an empty open draft (the chat's iouReportID): the approver does not require attention.
  • A held child plus an outstanding sibling preview whose report is not in Onyx: the approver still requires attention.
  • The existing #100365 tests stay green: an older all-held sibling plus a newer approvable sibling still requires attention, and the badge action is the newer report.

neerajbachani avatar Sep 30 '26 14:09 neerajbachani

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0170d6b02e9440e604

Proposal

What is the root cause of that problem?

In src/libs/ReportUtils.ts, getReasonAndReportActionThatRequiresAttention evaluates whether a chat report requires attention. When an employee submits an expense report and places its expenses on hold, getIOUReportActionWithBadge visits the chat report preview actions, evaluates isReportExcludedForHeldExpenses, and correctly determines that no action badge (APPROVE) should be returned for the approver (iouReportActionToApproveOrPay is undefined).

However, on the subsequent fallback path (lines 4649-4658), the code attempts to determine iouReportID:

const iouReportID = getIOUReportIDFromReportActionPreview(iouReportActionToApproveOrPay) ?? optionOrReport.iouReportID;

Because iouReportActionToApproveOrPay is undefined and optionOrReport.iouReportID is null (since iouReportID on the chat is cleared upon expense report submission), iouReportID resolves to undefined.

Consequently:

  1. getReportTransactions(undefined) returns an empty array [].
  2. isFallbackReportExcludedForHeldExpenses calls isReportExcludedForHeldExpenses(undefined, [], ...). Because hasOnlyHeldExpenses([]) is false, isFallbackReportExcludedForHeldExpenses evaluates to false.
  3. hasValidIOUAction then evaluates to true simply because optionOrReport.hasOutstandingChildRequest === true and !isFallbackReportExcludedForHeldExpenses is true.
  4. As a result, the chat report incorrectly receives reason: CONST.REQUIRES_ATTENTION_REASONS.HAS_CHILD_REPORT_AWAITING_ACTION, causing it to appear in the Inbox To-dos tab with a green dot and no action badge.

What changes do you think we should make in order to solve the problem?

  1. In src/libs/actions/IOU/ReportWorkflow.ts (getIOUReportActionWithBadge): When scanning the chat report's preview actions, if a preview action is skipped because isReportExcludedForHeldExpenses is true, track the report ID of that held child report (e.g. fullyHeldChildReportID) and return it alongside reportAction and actionBadge.

  2. In src/libs/ReportUtils.ts (getReasonAndReportActionThatRequiresAttention): Include fullyHeldChildReportID in the fallback resolution for iouReportID:

    const iouReportID = getIOUReportIDFromReportActionPreview(iouReportActionToApproveOrPay) ?? fullyHeldChildReportID ?? optionOrReport.iouReportID;
    

    This ensures that when all outstanding previews are on hold, isFallbackReportExcludedForHeldExpenses evaluates against the actual held child report rather than an undefined ID with empty transactions, correctly setting isFallbackReportExcludedForHeldExpenses to true and preventing the report from erroneously showing in the To-do tab.

  3. In tests/unit/ReportUtilsTest.ts: Update the unit test does not require attention when another user placed the hold to reflect production state where policyExpenseChat.iouReportID is null rather than artificially mocking iouReportID: expenseReportID.

What alternative solutions did you explore? (Optional)

  • Preventing optionOrReport.iouReportID from being cleared to null on submission. However, this alters optimistic data contracts across the application where chatReport.iouReportID specifically represents open unsubmitted drafts.
  • Scanning all report preview actions directly inside getReasonAndReportActionThatRequiresAttention. This would duplicate the preview action iteration that getIOUReportActionWithBadge already performs.

camesenin avatar Sep 30 '26 14:09 camesenin

βœ… Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Sep 30 '26 14:09 melvin-bot[bot]

Proposal updated, reworked the solution into a root fix and added a branch with tests

David-2002065 avatar Sep 30 '26 14:09 David-2002065