Skip to content

[Due for payment 2026-05-07] Show action badge (Approve) in LHN for individual expense reports #87712

Closed

Description

@MelvinBot

Problem

The "action badge" (e.g., Approve) currently only shows in the LHN (Left Hand Navigation) on the workspace chat. It does not appear when viewing an individual expense report directly.

Expected Behavior

  1. The action badge should appear in the LHN entry for individual expense reports — not just workspace chats.
  2. The badge should always show Approve as the action text, even when the actual button displayed is Review duplicates.

Slack thread

https://expensify.slack.com/archives/D0AH1G2F4HK/p1775682833688319

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. samranahm commented on Apr 11, 2026

    @samranahm
    Contributor

    Proposal

    What is the root cause of that problem?

    The action badge in the LHN is computed via getReasonAndReportActionThatRequiresAttention() in ReportUtils.ts, which calls getIOUReportActionWithBadge()

    getIOUReportActionWithBadge() searches the report's own actions for a REPORT_PREVIEW action and then checks whether the linked child expense report can be approved/paid/submitted. The problem is that REPORT_PREVIEW actions only exist in workspace chat reports (the parent chat that previews an expense report). When an individual expense report appears in the LHN, it has no REPORT_PREVIEW actions in its own action list, it is the expense report being previewed elsewhere. So the function finds nothing and returns no badge.

    so the badge logic assumes every LHN entry is a chat report with child expense previews, but never handles the case where the LHN entry is the expense report itself.

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

    In getReasonAndReportActionThatRequiresAttention() before calling getIOUReportActionWithBadge(), add a check if the report itself is an expense report isExpenseReport(optionOrReport), directly evaluate canApproveIOU() / canIOUBePaid() / canSubmitAndIsAwaitingForCurrentUser() on the report and return the appropriate badge without needing to find a REPORT_PREVIEW action.

    if (isExpenseReport(chatReport)) {
        let expenseBadge: ValueOf<typeof CONST.REPORT.ACTION_BADGE> | undefined;
        const parentChat = getReportOrDraftReport(chatReport?.chatReportID);
        if (
            canIOUBePaid(chatReport, parentChat, policy, undefined, undefined, undefined, undefined, invoiceReceiverPolicy) ||
            canIOUBePaid(chatReport, parentChat, policy, undefined, undefined, true, undefined, invoiceReceiverPolicy)
        ) {
            expenseBadge = CONST.REPORT.ACTION_BADGE.PAY;
        } else if (canApproveIOU(chatReport, policy, reportMetadata)) {
            expenseBadge = CONST.REPORT.ACTION_BADGE.APPROVE;
        } else if (
            canSubmitAndIsAwaitingForCurrentUser(
                chatReport,
                parentChat,
                policy,
                getReportTransactions(chatReport?.reportID),
                allTransactionViolations,
                deprecatedCurrentUserEmail,
                deprecatedUserAccountID,
                getAllReportActions(chatReport?.reportID),
            )
        ) {
            expenseBadge = CONST.REPORT.ACTION_BADGE.SUBMIT;
        }
        return {reportAction: undefined, actionBadge: expenseBadge};
    }

    Specifically:

    1. If isExpenseReport(optionOrReport) is true, call canApproveIOU(optionOrReport, policy, optionReportMetadata) — if it returns true, set actionBadge = APPROVE.
    2. Else check canIOUBePaid(optionOrReport, chatReport, policy, ...) > if true, set actionBadge = PAY.
    3. Else check canSubmitAndIsAwaitingForCurrentUser(...) > if true, set actionBadge = SUBMIT.
    4. Per the issue requirement, when the actual UI button would show "Review duplicates", the badge text should still read Approve this is already satisfied because canApproveIOU() returns true for reports needing approval regardless of whether duplicates exist, so the badge will correctly say Approve.

    What alternative solutions did you explore? (Optional)

    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.

  2. Vanshikadahaliya commented on Apr 13, 2026

    @Vanshikadahaliya

    Hi, I would like to work on this issue. Can you please assign it to me?

  3. melvin-bot commented on Apr 13, 2026

    @melvin-bot

    📣 @Vanshikadahaliya! 📣
    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>
    
  4. Vanshikadahaliya commented on Apr 13, 2026

    @Vanshikadahaliya

    Contributor details
    Your Expensify account email: vanshikad0023@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~0138f8dc915519337d

  5. melvin-bot commented on Apr 13, 2026

    @melvin-bot

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

  6. melvin-bot commented on Apr 14, 2026

    @melvin-bot

    @aimane-chnaif Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  7. melvin-bot commented on Apr 16, 2026

    @melvin-bot

    @aimane-chnaif Eep! 4 days overdue now. Issues have feelings too...

  8. aimane-chnaif commented on Apr 19, 2026

    @aimane-chnaif
    Contributor

    @MelvinBot post your proposal

  9. MelvinBot commented on Apr 19, 2026

    @MelvinBot
    ContributorAuthor

    Proposal

    What is the root cause of that problem?

    getReasonAndReportActionThatRequiresAttention delegates badge computation to getIOUReportActionWithBadge (ReportWorkflow.ts:265), which searches the report's own actions for a REPORT_PREVIEW action and then evaluates whether the linked child expense report can be paid/approved/submitted. REPORT_PREVIEW actions only exist in workspace chat reports (they are the parent-side preview of a child expense report). When the LHN entry is the expense report itself, it contains no REPORT_PREVIEW actions, so getIOUReportActionWithBadge returns no match and no badge.

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

    In getReasonAndReportActionThatRequiresAttention (ReportUtils.ts:4308), before calling getIOUReportActionWithBadge, add a short-circuit for expense reports: if isExpenseReport(optionOrReport) is true, directly evaluate canIOUBePaid/canApproveIOU/canSubmitAndIsAwaitingForCurrentUser on the report itself (it is the IOU report) using getReportOrDraftReport(optionOrReport.chatReportID) as the parent chat, and return the appropriate badge without needing a REPORT_PREVIEW action. The priority order (pay > approve > submit) should match what getIOUReportActionWithBadge already uses. Per the issue requirement, "Review duplicates" cases still get an Approve badge because canApproveIOU returns true regardless of duplicate state.

    What alternative solutions did you explore? (Optional)

    Modifying getIOUReportActionWithBadge itself to handle expense reports was considered, but that function's contract is to return a specific reportAction (the REPORT_PREVIEW action) alongside the badge. For expense reports there is no such action to return, so adding the logic in the caller (getReasonAndReportActionThatRequiresAttention) is a cleaner separation.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  10. aimane-chnaif commented on Apr 19, 2026

    @aimane-chnaif
    Contributor

    @MelvinBot implement this

  11. MelvinBot commented on Apr 19, 2026

    @MelvinBot
    ContributorAuthor

    Draft PR created: #88294
    Please mark it as "Ready for review" when it is ready for review.

  12. 12 remaining items

  13. aimane-chnaif commented on May 1, 2026

    @aimane-chnaif
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: new feature

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion:

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue: https://github.com/Expensify/Expensify/issues/634722

    Regression Test Proposal

    Precondition:

    • A: workspace owner
    • B: workspace member & submitter
    • C: workspace member & approver

    Test:

    1. B: Submit expense
    2. C: Leave the B's workspace chat
    3. C: Open B's expense report from search router
    4. C: Verify that "Approve" badge shows in LHN

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-40fe-a28f-71b1-0d04c36b33d4
  14. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on May 1, 2026
  15. melvin-bot commented on May 6, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  16. melvin-bot commented on May 7, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  17. mallenexpensify commented on May 8, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @aimane-chnaif paid $250 via Upwork

    @aimane-chnaif can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022052539212036214369

  18. aimane-chnaif commented on May 8, 2026

    @aimane-chnaif
    Contributor

    @mallenexpensify accepted offer

  19. mallenexpensify commented on May 9, 2026

    @mallenexpensify
    Contributor

    @aimane-chnaif paid, summary updated above. Thx.

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionDailyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions