Skip to content

Action badge follow-ups: deep link to reportAction and remove Pinned text#85442

Draft
MelvinBot wants to merge 3 commits intomainfrom
claude-actionBadgeFollowUps
Draft

Action badge follow-ups: deep link to reportAction and remove Pinned text#85442
MelvinBot wants to merge 3 commits intomainfrom
claude-actionBadgeFollowUps

Conversation

@MelvinBot
Copy link
Contributor

Explanation of Change

This PR addresses two follow-up fixes for the action badge feature (#84764, PR #85025):

  1. LHN navigation deep links to reportAction — When pressing on a row in the LHN that has a GBR/RBR action badge, the navigation now deep links directly to the specific reportAction that requires attention (e.g. the REPORT_PREVIEW action needing approval/payment/submission), rather than scrolling to the bottom of the chat. This is done by threading the actionBadgeReportActionID through the derived report attributes → OptionDataSidebarLinks.showReportPageNavigation.navigate.

  2. Removed "Pinned" text from badge — The Pinned badge in the LHN now shows only the pin icon without the "Pinned" text label. The non-production path previously rendered a Badge component with both icon and text; it now renders just the icon, matching the production behavior.

Fixed Issues

$ #85436
PROPOSAL:

Tests

  1. Login to any account with a workspace
  2. Create a draft expense without any violation, submit it, then approve it
  3. Observe the LHN — verify that pressing on a row with an action badge (Submit, Approve, Pay) navigates directly to the relevant report action, not to the bottom of the chat
  4. Create an expense with a violation
  5. Verify that pressing on a row with the Fix badge navigates to the relevant action
  6. Pin a chat and verify the pinned badge shows only the pin icon without the "Pinned" text label
  7. Verify that all other GBR/RBR dots (without action badges) still navigate normally
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests — navigation and badge rendering are client-side only.

QA Steps

Same as Tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

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

Deep link to the specific reportAction when pressing an LHN row with
GBR/RBR action badge, instead of scrolling to the bottom. Remove the
"Pinned" text label from the pin badge, showing only the pin icon.

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
if (SidebarUtils.shouldShowRedBrickRoad(report, chatReport, reportActionsList, hasAnyViolations, reportErrors, transactions, transactionViolations, !!isReportArchived)) {
brickRoadStatus = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR;
actionBadge = CONST.REPORT.ACTION_BADGE.FIX;
actionBadgeReportActionID = greenBadgeReportActionID;
Copy link
Contributor

Choose a reason for hiding this comment

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

@MelvinBot this is completely wrong logic.
Your PR is basically same as #85192 I already created.

The solution I'm looking for is to get correct reportActionID for various types of RBRs.
i.e. RBR when violation exists for expense (shouldDisplayViolationsRBRInLHN = true): how to get reportActionID for report preview with violation?
Can you help with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right — the logic here is wrong. Using greenBadgeReportActionID for the RBR case is incorrect because the GBR reportAction (e.g. an approve/pay action) is unrelated to the violation that caused the RBR.

To answer your question about getting the correct reportActionID when shouldDisplayViolationsRBRInLHN is true:

The key insight is that shouldDisplayViolationsRBRInLHN scans all expense reports under the same policyID (via reportsByPolicyID) and finds a potentialReport with violations — but it only returns a boolean, discarding which report matched.

To get the REPORT_PREVIEW action:

  1. Refactor shouldDisplayViolationsRBRInLHN (or create a sibling function) to return the violating potentialReport.reportID instead of just true.

  2. Then in getReasonAndReportActionThatHasRedBrickRoad (which already receives the expense chat's reportActions), find the REPORT_PREVIEW action whose originalMessage.linkedReportID matches that violating report:

const violatingReportID = getViolatingReportIDForLHN(report, transactionViolations);
if (violatingReportID) {
    const reportPreviewAction = Object.values(reportActions ?? {}).find(
        (action) => isReportPreviewAction(action)
            && getOriginalMessage(action)?.linkedReportID === violatingReportID,
    );
    return {
        reason: CONST.RBR_REASONS.HAS_TRANSACTION_THREAD_VIOLATIONS,
        reportAction: reportPreviewAction,
    };
}

The REPORT_PREVIEW → child report link is via originalMessage.linkedReportID (defined in OriginalMessageReportPreview at src/types/onyx/OriginalMessage.ts:333). There's also an existing pattern for this in getReportPreviewAction at src/libs/actions/IOU/index.ts:1205-1215.

The same approach applies to the HAS_VIOLATIONS reason — find the action whose linked child report has violations.

I'll close this PR since your PR #85192 already takes the correct approach of calling getReasonAndReportActionThatHasRedBrickRoad for the RBR case.

Copy link
Contributor

Choose a reason for hiding this comment

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

@MelvinBot implement your suggestion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implemented the suggestion in 30c7ca1. Here's what changed:

  1. ReportUtils.ts — Added getViolatingReportIDForLHN, a companion to shouldDisplayViolationsRBRInLHN that returns the violating child report's reportID (uses .find() instead of .some()).

  2. SidebarUtils.ts — Modified getReasonAndReportActionThatHasRedBrickRoad to call getViolatingReportIDForLHN for the HAS_TRANSACTION_THREAD_VIOLATIONS case, then finds the REPORT_PREVIEW action whose originalMessage.linkedReportID matches the violating report.

  3. reportAttributes.ts — Replaced shouldShowRedBrickRoad (boolean) with getReasonAndReportActionThatHasRedBrickRoad (returns reason + reportAction), and uses reasonAndReportAction.reportAction?.reportActionID instead of the incorrect greenBadgeReportActionID.

Note: For the HAS_VIOLATIONS and HAS_ERRORS cases, getReasonAndReportActionThatHasRedBrickRoad already returns the appropriate reportAction (from getAllReportActionsErrorsAndReportActionThatRequiresAttention for errors) or undefined when no specific action is identifiable.

MelvinBot and others added 2 commits March 16, 2026 17:30
Instead of reusing the GBR (green badge) reportActionID for the RBR
case, call getReasonAndReportActionThatHasRedBrickRoad to get the
actual reportAction that caused the red brick road indicator.

For the HAS_TRANSACTION_THREAD_VIOLATIONS case, add
getViolatingReportIDForLHN which returns the violating child report's
ID, then find the matching REPORT_PREVIEW action via linkedReportID.

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
…tting

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
@MelvinBot
Copy link
Contributor Author

Fixed the failing Prettier check: ran prettier on src/libs/SidebarUtils.ts to fix import ordering (isReportPreviewAction, getViolatingReportIDForLHN) and inline formatting of a .find() callback.

@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/components/LHNOptionsList/OptionRowLHN.tsx 79.50% <100.00%> (+0.71%) ⬆️
src/components/LHNOptionsList/OptionRowLHNData.tsx 82.85% <ø> (ø)
src/libs/SidebarUtils.ts 80.13% <100.00%> (+0.10%) ⬆️
...bs/actions/OnyxDerived/configs/reportAttributes.ts 96.00% <100.00%> (+0.09%) ⬆️
src/pages/inbox/sidebar/SidebarLinks.tsx 92.00% <100.00%> (ø)
src/libs/ReportUtils.ts 77.18% <93.54%> (+0.01%) ⬆️
... and 22 files with indirect coverage changes

@MelvinBot
Copy link
Contributor Author

The Prettier check failure on src/libs/SidebarUtils.ts was already fixed in commit e37dd5b. All checks are now passing — tests (all 8 jobs), typecheck, ESLint, Prettier, builds, storybook, perf-tests, and spellcheck.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants