App icon indicating copy to clipboard operation
App copied to clipboard

[Due for payment 2026-11-14] [$175] LHN shows a green dot instead of an `Add` badge for an empty report

Open melvin-bot[bot] opened this issue 1 month ago • 27 comments

Problem An empty expense report that needs attention shows only a green dot in the LHN, with no action badge. The report itself pushes the user toward a green Add button. The LHN row should match it.

Expected The LHN row for an empty report that needs attention shows an Add action badge.

Actual The LHN row shows only a green dot.

Steps to reproduce

  1. Create an empty expense report in a workspace chat.
  2. Look at the report's row in the LHN.
  3. Note that it shows a green dot, not an Add badge.

Where to look

  • The LHN badge comes from actionBadge. It is set by generateReportAttributes() in src/libs/ReportUtils.ts and passed through src/libs/actions/OnyxDerived/configs/reportAttributes.ts.
  • When requiresAttention is true but no actionBadge is set, the row shows a green dot only.
  • The fix is likely a new ADD value in CONST.REPORT.ACTION_BADGE and a common.actionBadge.add translation. generateReportAttributes() would return it for empty open reports the user can add expenses to.
  • Don't show Add to users who can't add expenses, such as approve-only members. See #104907.

Reported in Slack.

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

melvin-bot[bot] avatar Oct 27 '26 05:10 melvin-bot[bot]

Proposal

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

An empty open expense report shows a bare green dot in the LHN, with no action badge. The report view shows a green Add expense button, so the LHN row should show an Add badge.

What is the root cause of that problem?

The dot and the badge come from different checks. For an empty report, the dot check passes but no badge check does.

  • The dot turns on from a flag. Creating a report on a manually submitted workspace sets hasOutstandingChildRequest: true on the workspace chat. This happens for any open report, with or without expenses (ReportUtils.ts:13274-13281). That flag alone makes hasValidIOUAction true (ReportUtils.ts:5232-5235).
  • No badge applies. getBadgeFromIOUReport only knows Pay, Approve and Submit (ReportUtils.ts:3520-3579). Submit needs at least one expense (ReportUtils.ts:3516). So it returns undefined.
  • The result has a reason but no badge. The HAS_CHILD_REPORT_AWAITING_ACTION return passes actionBadge: undefined (ReportUtils.ts:5281-5287). InfoBadge then falls back to the green dot (InfoBadge.tsx:37-53).

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

  1. Add ADD: 'add' to CONST.REPORT.ACTION_BADGE (CONST/index.ts:2054-2060). Add common.actionBadge.add (Add) to every language file (en.ts:169-175). InfoBadge needs no change.
  2. In getBadgeFromIOUReport, after the Submit check, return ADD when the report is an open expense report with no expenses and canAddTransaction is true. This is the same rule the report uses for its Add expense button (isAddExpenseAction). Because it runs in the report preview loop, the row also gets a click target, just like Submit, Approve and Pay. Submit needs an expense, so the two badges never overlap.
  3. Keep approve-only members out (Next step shows "Waiting for you to add expenses", LHN shows GBR for approve-only member). canAddTransaction already returns false for them through canCreateExpensesOnPolicy (ReportUtils.ts:3226), so they won't get Add. The green dot itself is a separate bug that #104907 tracks.
  4. Add unit tests under getReasonAndReportActionThatRequiresAttention in tests/unit/ReportUtilsTest.ts:
    • An empty report for a submitter returns actionBadge: ADD.
    • An empty report for an approve-only member returns no ADD.

What alternative solutions did you explore? (Optional)

Stop the dot instead of adding a badge, by not counting the flag for empty reports. This hides a real next step that the report view asks the user to take, so I don't recommend it.

Notes and confidence
  • Confidence: medium. I traced the code path but did not reproduce it in the app. The test account could not finish onboarding.
  • Which row: on the client, the flag is only set on the workspace chat, so the fix covers the workspace chat row. If the expense report's own row also shows the dot, the backend is setting the flag on the report too. That case would need the badge computed outside the preview loop.
  • canAddTransaction reads the policy from a module-level cache. If that matters inside the derived value, call canCreateExpensesOnPolicy(policy) with the policy already passed in.

Related issue: LHN — some rows show a green dot while others show an action badge has the same badge-less fallback, caused there by unread mentions.


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


view run

MelvinBot avatar Oct 27 '26 05:10 MelvinBot

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

melvin-bot[bot] avatar Oct 27 '26 06:10 melvin-bot[bot]

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

melvin-bot[bot] avatar Oct 27 '26 06:10 melvin-bot[bot]

Proposal

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

An empty expense report requiring attention displays a green dot in the LHN instead of an Add action badge. The badge should match the report’s available action and must not appear for users who cannot add expenses.

What is the root cause of that problem?

The proposed cause is plausible but remains unverified. The supplied source snippets contain imports, not the relevant implementations. The referenced commit could not be retrieved, and no Expensify checkout was available for reproduction or testing.

According to the supplied MelvinBot trace:

  • src/libs/ReportUtils.ts:3520–3579: getBadgeFromIOUReport() produces existing payment, approval, and submission badges, but no Add badge.
  • src/libs/ReportUtils.ts:5281–5287: an attention result can carry an undefined badge.
  • src/components/LHNOptionsList/OptionRowLHN/OptionRow/InfoBadge.tsx:37–53: that combination renders the dot.

These are references supplied in the proposal, not independently verified line numbers.

The decisive unresolved question is which LHN row executes this path. MelvinBot acknowledges that its change targets the workspace chat’s report-preview loop. That does not establish that it fixes the expense report’s own row identified in the issue.

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

Refine MelvinBot’s proposal before accepting implementation. Its constant and translation additions are reasonable, but its placement and reactive dependencies need evidence.

The smallest justified implementation should:

  1. Add ADD: 'add' to CONST.REPORT.ACTION_BADGE.
  2. Add common.actionBadge.add using the repository’s required localization workflow.
  3. Assign ADD in the existing badge computation reached by the affected row, using the same eligibility conditions as the report’s primary Add expense action.
  4. Preserve existing badge priority and the navigation target corresponding to the selected badge.
  5. Ensure the derived attributes update when the policy or report data governing eligibility changes.

Do not substitute these weaker conditions:

report.total === 0

A zero monetary total does not prove that a report contains no expenses.

canCreateExpensesOnPolicy(policy)

That policy permission alone does not establish equivalence with the complete report-level eligibility check. Replacing canAddTransaction() with it requires inspecting both implementations.

An exact, production-ready TypeScript diff cannot be substantiated from the provided imports. Inventing function signatures, insertion points, or verified line numbers would violate the required evidence standard. The relevant function bodies and derived-value dependencies must be available before presenting such a diff.

What alternative solutions did you explore? (Optional)

MelvinBot’s proposal has three acceptance-blocking gaps:

  • Unproven row coverage. A preview-loop change may cover the parent workspace chat while missing the report row. Its backend explanation is a hypothesis, not evidence.
  • Unproven permission reactivity. The proposal identifies a module-level policy cache but supplies no test showing that a permission change recomputes the derived badge. A correct initial result does not prove correct subsequent behavior.
  • Insufficient regression coverage. Two static permission tests do not establish badge transitions, navigation correctness, or existing-action precedence.

These gaps justify refinement; they do not prove that MelvinBot’s implementation fails.

Removing the attention flag is also unsupported: it changes attention behavior rather than demonstrating the requested badge fix. Adding a rendering-only fallback in InfoBadge would place report eligibility decisions in the presentation layer.

There is no evidence here supporting a security finding or a CVSS rating.

What automated tests can you add to prevent this from re-occurring?

Add regression cases in tests/unit/ReportUtilsTest.ts, under the existing attention-result suite:

Case Required assertion
Eligible submitter, empty open expense report actionBadge equals CONST.REPORT.ACTION_BADGE.ADD; the returned action targets that report
Approve-only member, same report actionBadge is not ADD
Report containing a zero-value expense Emptiness is determined from expenses, not the monetary total
Submitted, approved, or paid report No inappropriate ADD; existing action behavior remains intact
Workspace chat with multiple report previews Selected badge and navigation target refer to the same child report

Add a test at the derived-attributes layer, using real Onyx updates:

  1. Seed an eligible empty report and assert ADD.
  2. Add its first expense and assert recomputation to the appropriate existing result.
  3. Remove that expense and assert ADD returns.
  4. Change the policy to deny expense creation and assert ADD disappears without recreating the report.

Reproduce the issue first to establish whether the affected row is the workspace chat or the expense report. Cover both if both reproduce.

Validation status: No reproduction, TypeScript check, or Jest execution was completed. These are proposed acceptance tests, not passing results.

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

camesenin avatar Oct 27 '26 06:10 camesenin

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Oct 27 '26 06:10 melvin-bot[bot]

@MelvinBot provide test branch for your proposal

Eskalifer1 avatar Oct 27 '26 08:10 Eskalifer1

🤖 The test branch is ready: claude-emptyReportAddBadge (commit 7421f14).

What changed

  • Added CONST.REPORT.ACTION_BADGE.ADD and a common.actionBadge.add translation in all 11 language files. Each translation reuses that file's existing common.add text.
  • getBadgeFromIOUReport now returns ADD for an empty open expense report when canAddTransaction is true. That is the same check behind the report's Add expense button.

There are two differences from the proposal. Both keep existing behavior safe:

  • ADD only applies when the workspace chat already has hasOutstandingChildRequest. It can label an existing green dot, but it never creates a new one.
  • ADD is a fallback in getIOUReportActionWithBadge. If another report in the same chat needs Submit, Approve or Pay, that badge still wins, even when the empty report is older.

How to test

  1. Sign in as a workspace member who can add expenses, on a workspace where reports are submitted manually.
  2. Create an empty report in the workspace chat.
  3. Check the workspace chat row in the LHN. It should show a green Add badge, not a bare dot.
  4. Repeat as an approve-only member. That member should not see Add.

Checks run: two new unit tests in tests/unit/ReportUtilsTest.ts (Add for a submitter, no Add for an approve-only member). All 1,764 tests in ReportUtilsTest, reportAttributesTest, OnyxDerivedTest and SidebarUtilsTest pass. Typecheck, ESLint and spell check also pass. I haven't checked the flow in a browser.


view run

MelvinBot avatar Oct 27 '26 08:10 MelvinBot

We can move forward with Melvin proposal here

:ribbon: :eyes: :ribbon: C+ reviewed

Eskalifer1 avatar Oct 27 '26 08:10 Eskalifer1

Triggered auto assignment to @mollfpr, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

melvin-bot[bot] avatar Oct 27 '26 08:10 melvin-bot[bot]

Proposal

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

An empty open expense report requiring user attention currently displays only a plain green dot in the Left-Hand Navigation (LHN) with no action badge. Inside the report itself, the UI presents a prominent green Add expense button. The LHN row should consistently display an Add action badge instead of a bare green dot, matching the primary action available to the user.

What is the root cause of that problem?

  1. In src/CONST/index.ts, CONST.REPORT.ACTION_BADGE currently defines:
    ACTION_BADGE: {
        SUBMIT: 'submit',
        APPROVE: 'approve',
        PAY: 'pay',
        FIX: 'fix',
        TASK: 'task',
    },
    
    An ADD badge type does not exist in the constants.
  2. In src/libs/ReportUtils.ts, getBadgeFromIOUReport checks for PAY, APPROVE, and SUBMIT. When an open expense report has no transactions (reportTransactions.length === 0), it returns undefined.
  3. Consequently, in generateReportAttributes(), requiresAttention is evaluated as true (triggering the green indicator), but actionBadge remains undefined, causing the LHN row component to fall back to rendering a bare green dot.

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

  1. Add ADD to ACTION_BADGE constant: In src/CONST/index.ts:
ACTION_BADGE: {
    SUBMIT: 'submit',
    APPROVE: 'approve',
    PAY: 'pay',
    FIX: 'fix',
    TASK: 'task',
    ADD: 'add',
},
  1. Add localization string: In src/languages/en.ts and src/languages/es.ts under common.actionBadge:
add: 'Add',
  1. Return ADD badge for empty open reports where the user can add expenses: In src/libs/ReportUtils.ts, inside getBadgeFromIOUReport: When reportTransactions.length === 0 and the report is an open expense report (isOpenExpenseReport(iouReport)): Ensure the badge is only displayed to users who have permission to add expenses (i.e. report owner or members with write permissions, excluding approve-only members as per #104907):
if (isExpenseReport(iouReport) && isOpenExpenseReport(iouReport) && reportTransactions.length === 0) {
    if (canUserPerformWriteAction(iouReport) && canAddExpense(iouReport, policy)) {
        return CONST.REPORT.ACTION_BADGE.ADD;
    }
}
  1. Update badge rendering in LHN row: In the LHN row component rendering action badges (src/pages/home/sidebar/SidebarUtils.ts / OptionRowLHNData), map CONST.REPORT.ACTION_BADGE.ADD to display the localized common.actionBadge.add text inside the badge container.

What alternative solutions did you explore? (Optional)

Displaying a generic SUBMIT badge; however, an empty report cannot be submitted until at least one expense is added, so an Add badge directly communicates the required user action and prevents confusing the user.

Test Result / Verification:

  1. Log in and open any workspace chat.
  2. Create an empty expense report (e.g. submit an expense and delete it, or start an empty expense report).
  3. Observe the report's row in the Left-Hand Navigation (LHN).
  4. Verify the row displays an Add action badge instead of a plain green dot.
  5. Log in as an approve-only workspace member who cannot add expenses to this report; verify the Add badge is not shown.
  6. Add an expense to the report; verify the badge updates according to report state (e.g. Submit).

Enes2553 avatar Oct 27 '26 18:10 Enes2553

Looking into this today

youssef-lr avatar Oct 28 '26 01:10 youssef-lr

Agreed with Melvin's solution as well and looks like no BE work is needed here so removing my assignemnt.

youssef-lr avatar Oct 28 '26 14:10 youssef-lr

Proposal

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

An empty open expense report requiring attention currently displays only a plain green dot in the Left-Hand Navigation (LHN) with no action badge. Inside the report view, the UI prompts the user with a green Add button. The LHN row should display a matching Add action badge instead of an unadorned green dot.

What is the root cause of that problem?

  1. In src/libs/ReportUtils.ts (lines 3549–3605), getBadgeFromIOUReport() evaluates candidate action badges in sequence:
    • canBePaidNow / canBePaidElsewhere -> CONST.REPORT.ACTION_BADGE.PAY
    • canApproveIOU -> CONST.REPORT.ACTION_BADGE.APPROVE
    • canSubmitAndIsAwaitingForCurrentUser -> CONST.REPORT.ACTION_BADGE.SUBMIT When an open expense report has no transactions (reportTransactions is empty), none of these conditions evaluate to true, so getBadgeFromIOUReport falls through and returns undefined at line 3604.
  2. In generateReportAttributes() (src/libs/ReportUtils.ts, line 14789), getReasonAndReportActionThatRequiresAttention() returns reason but actionBadge: undefined. When requiresAttention is true without an actionBadge, BaseOptionListItem renders only the green indicator dot.
  3. CONST.REPORT.ACTION_BADGE in src/CONST/index.ts currently lacks an ADD badge type, and src/languages/en.ts lacks the common.actionBadge.add translation key.

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

  1. Add ADD to CONST.REPORT.ACTION_BADGE in src/CONST/index.ts:

        ACTION_BADGE: {
            PAY: 'pay',
            APPROVE: 'approve',
            SUBMIT: 'submit',
    +       ADD: 'add',
        },
    
  2. Add translation key in src/languages/en.ts (and corresponding locale files):

        actionBadge: {
            pay: 'Pay',
            approve: 'Approve',
            submit: 'Submit',
    +       add: 'Add',
        },
    
  3. Return CONST.REPORT.ACTION_BADGE.ADD in src/libs/ReportUtils.ts (getBadgeFromIOUReport) around line 3604:

        if (isWaitingSubmitFromCurrentUser) {
            return CONST.REPORT.ACTION_BADGE.SUBMIT;
        }
    +   if (
    +       isOpenExpenseReport(iouReport) &&
    +       !reportTransactions?.length &&
    +       (isReportOwner(iouReport, currentUserAccountID) || isAllowedToComment(iouReport)) &&
    +       !isPolicyExpenseChat(chatReport)
    +   ) {
    +       return CONST.REPORT.ACTION_BADGE.ADD;
    +   }
        return undefined;
    
  4. Add Unit Test in tests/unit/ReportUtilsTest.ts:

    • Verify that an open expense report with 0 transactions owned by the current user returns CONST.REPORT.ACTION_BADGE.ADD.

What alternative solutions did you explore? (Optional)

  • Relying solely on requiresAttention without a badge: Rejected because empty reports direct the user to take action (Add expense). Matching the LHN badge with the primary action button aligns with Expensify's UX guidelines for Pay, Approve, and Submit.

duongynhi000005-oss avatar Nov 01 '26 19:11 duongynhi000005-oss

@Eskalifer1 let's moving forward with Melvin proposal!

mollfpr avatar Nov 02 '26 09:11 mollfpr

@MelvinBot implement this

Eskalifer1 avatar Nov 02 '26 09:11 Eskalifer1

🤖 Draft PR created: Show an Add badge in the LHN for an empty report the user can add expenses to Please mark it as "Ready for review" or ask me to do that for you when it is ready for review.

It implements the accepted proposal, using the same commit as the earlier test branch, on a fresh branch from main.

Checks run: 2,887 unit tests across the badge, LHN and derived-value suites pass. Typecheck, ESLint and spell check pass.

Not verified: I couldn't check the flow in a browser because the test session failed to load. The Tests and QA sections are left for you to fill in.

MelvinBot avatar Nov 02 '26 09:11 MelvinBot

📣 @Eskalifer1 We're missing your Upwork ID to automatically send you an offer for the Reviewer role. Once you apply to the Upwork job, your Upwork ID will be stored and you will be automatically hired for future jobs!

melvin-bot[bot] avatar Nov 02 '26 13:11 melvin-bot[bot]

Proposal

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

When a user creates an empty expense report on a workspace configured with manual submission, the report view displays a green "Add expense" button in the header and hasOutstandingChildRequest is true on the workspace chat, causing the LHN row to display a plain green dot (GBR) instead of an "Add" action badge.

What is the root cause of that problem?

In src/libs/ReportAttributesDerivedValue.ts and src/libs/SidebarUtils.ts (getOptionData), when a workspace chat has hasOutstandingChildRequest: true due to an empty open child expense report (total === 0, no transactions), brickRoadIndicator evaluates to CONST.BRICK_ROAD_INDICATOR_STATUS.INFO (green dot).

When computing the LHN actionBadge for the report row (getActionBadge in src/libs/ReportAttributesDerivedValue.ts / src/libs/ReportUtils.ts), the badge logic checks whether the next action is SUBMIT, APPROVE, PAY, or MARK_AS_PAID. Because the open report has zero transactions (isEmptyExpenseReport), canSubmitReport is false and canAddTransaction is true. Since there is no CONST.REPORT.ACTION_BADGE.ADD branch in getActionBadge, actionBadge returns undefined, and OptionRowLHN falls back to rendering a bare green dot (BrickRoadIndicator) instead of an "Add" pill badge.

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

  1. In src/CONST/index.ts, add ADD: 'add' to CONST.REPORT.ACTION_BADGE.
  2. In src/libs/ReportAttributesDerivedValue.ts (and src/libs/SidebarUtils.ts where actionBadge is mapped to translated badge text in OptionRowLHN.tsx), check if the report (or its single outstanding child report) is an open empty expense report where the user can add expenses (canAddTransaction(report) && isEmptyReport(report)), and return CONST.REPORT.ACTION_BADGE.ADD.
  3. In src/components/LHNOptionsList/OptionRowLHN.tsx, map CONST.REPORT.ACTION_BADGE.ADD to translate('common.add') so the LHN renders the green "Add" badge instead of an unlabeled green dot.

What alternative solutions did you explore? (Optional)

We considered suppressing hasOutstandingChildRequest / the green dot completely for empty reports, but product confirmed that when the green "Add expense" button is shown as the primary action on the report, the LHN should show the corresponding "Add" badge rather than a plain green dot.

jeffrey-graham avatar Nov 07 '26 07:11 jeffrey-graham

📣 @jeffrey-graham! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

melvin-bot[bot] avatar Nov 07 '26 07:11 melvin-bot[bot]

@Eskalifer1

The solution for this issue has been :rocket: deployed to production :rocket: in version 9.5.33-1 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

  • https://github.com/Expensify/App/pull/105604

If no regressions arise, payment will be issued on 2026-11-14. :confetti_ball:

The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the Contributor+ Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]

melvin-bot[bot] avatar Nov 07 '26 20:11 melvin-bot[bot]