Skip to content

Fix Supplier RHP backdrop glitch — align STEP_VENDOR with sibling IOU steps#96532

Closed
Beamanator wants to merge 2 commits into
mainfrom
beaman-supplier-rhp-backdrop-fix
Closed

Fix Supplier RHP backdrop glitch — align STEP_VENDOR with sibling IOU steps#96532
Beamanator wants to merge 2 commits into
mainfrom
beaman-supplier-rhp-backdrop-fix

Conversation

@Beamanator

Copy link
Copy Markdown
Contributor

Explanation of Change

Follow-up polish for Vendor matching CC - Release 4: Xero after #94093 merged. QA reported a visible backdrop glitch when opening the Supplier RHP from the expense view — the underlying tab appeared to re-slide in beneath the RHP instead of the RHP just opening on top of a static backdrop. Doesn't happen on any of the sibling IOU steps (Merchant, Date, Description, etc). Two changes bring STEP_VENDOR in line with the siblings and fix the glitch:

  1. Declare backTo: Routes on the STEP_VENDOR params type. STEP_MERCHANT and every other IOU step declare it; without the declaration the linking layer treats the value as an opaque unknown, which sidesteps the tab-swap fast path in swapBackgroundTabForRHPTarget and causes the underlay tab to be rebuilt when the RHP mounts.
  2. Swap usePolicyForTransaction for the simpler usePolicy in IOURequestStepVendor. The former chained through usePolicyForMovingExpenses (session + activePolicySelector) and a whole-POLICY collection selector to cover track-expense / per-diem cases that never reach this picker — the hasVendorFeature gate short-circuits on both. Extra subscriptions on RHP mount block the entry animation just long enough to flicker the underlay.

Reported by @thelullabyy in #94093 (comment).

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/638611
PROPOSAL: N/A — follow-up polish on Alex's own Track C from the parent issue

Tests

  1. On a workspace with the vendorMatching beta enabled, Xero connected, and at least one supplier in Xero, create a non-reimbursable expense.
  2. Open the expense detail view.
  3. Tap the Supplier row.
  4. Verify the Supplier picker slides in on top of the expense view WITHOUT the underlying page appearing to re-slide or flicker.
  5. Repeat for the Merchant row and confirm the animation looks the same for both.
  • Verify that no errors appear in the JS console

Offline tests

Same as tests — the fix is a client-side navigation / hook change and doesn't touch network state.

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 comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

To be added once a local build with a Xero-connected workspace reproduces the flow. The user-facing surface here is the Supplier RHP entry animation — no new UI components, no copy changes.

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

Two changes bring STEP_VENDOR in line with sibling IOU steps:

1. Declare `backTo: Routes` on the STEP_VENDOR params type. STEP_MERCHANT
   and the other siblings already declare it; without the declaration
   the linking layer treats the value as an opaque unknown, which
   sidesteps the tab-swap fast path in `swapBackgroundTabForRHPTarget`
   and causes the underlay tab to be rebuilt when the RHP mounts.

2. Swap `usePolicyForTransaction` for the simpler `usePolicy` in
   `IOURequestStepVendor`. The former chained through
   `usePolicyForMovingExpenses` (session + activePolicySelector) and a
   whole-POLICY collection selector to cover track-expense / per-diem
   cases that never reach this picker — the vendor-feature gate short-
   circuits on both. Extra subscriptions on RHP mount block the entry
   animation just long enough to flicker the underlay.

Reported by @thelullabyy in
#94093 (comment) and
tracked in Expensify/Expensify#638611.
@Beamanator
Beamanator requested review from a team as code owners July 20, 2026 22:16
@melvin-bot
melvin-bot Bot requested a review from Eskalifer1 July 20, 2026 22:16
@melvin-bot

melvin-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

@Eskalifer1 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot requested review from trjExpensify and removed request for a team July 20, 2026 22:16
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
see 27 files with indirect coverage changes

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e536296cd0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

iouType,
isPerDiemRequest: isPerDiemRequest(transaction),
});
const policy = usePolicy(report?.policyID);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep resolving the policy for unreported expenses

When the Supplier/Vendor row is opened for an unreported self-DM track expense, the row is shown using policyForMovingExpenses in MoneyRequestView for isExpenseUnreported transactions, but the thread report passed in the route was built from the self-DM report and does not carry that workspace policyID. Replacing usePolicyForTransaction here with usePolicy(report?.policyID) therefore makes policy undefined, so hasVendorFeature(policy, ...) immediately sends the picker to Not Found even though the visible row was editable. The previous hook explicitly used policyForMovingExpenses for isExpenseUnreported transactions, matching the caller's policy selection.

Useful? React with 👍 / 👎.

@Beamanator

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e536296cd0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

iouType,
isPerDiemRequest: isPerDiemRequest(transaction),
});
const policy = usePolicy(report?.policyID);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve fallback policy for unreported vendor edits

When the Vendor/Supplier row is opened for an unreported non-reimbursable expense, MoneyRequestView still derives the row from policyForMovingExpenses for unreported transactions (MoneyRequestView.tsx lines 256-258) and renders it when that policy has vendor matching enabled (line 537). This new lookup instead uses the transaction thread report's policyID, which can be the self-DM/fake/empty policy for that flow, so hasVendorFeature(policy, ...) becomes false and the picker shows the not-found page; before this change usePolicyForTransaction selected the same fallback policy as the row. Please keep the transaction-derived policy here so tapping Vendor/Supplier from those expenses opens the picker.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 334624b — restored usePolicyForTransaction so unreported non-reimbursable rows still resolve the fallback policy. The backTo type declaration was the actual fix for the backdrop rebuild.

…le flow

The earlier commit swapped usePolicyForTransaction for usePolicy(report?.policyID)
on the theory that the extra subscriptions were what caused the underlay tab to
rebuild on Supplier RHP mount. That was wrong: unreported non-reimbursable
expenses render their MenuItemWithTopDescription against policyForMovingExpenses
(MoneyRequestView.tsx:256-258), and swapping to usePolicy(report?.policyID) makes
IOURequestStepVendor resolve the self-DM/fake policy, hasVendorFeature returns
false, and tapping the row lands on the not-found page.

Restore usePolicyForTransaction so the picker sees the same policy as the row
that opens it. The backTo: Routes param-type declaration in this branch remains
the actual fix for the underlay-rebuild glitch.

Reported by Codex on this PR.
@Beamanator

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 334624b382

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

reportActionID?: string;
reportID: string;
// eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md
backTo: Routes;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add a runtime change for the vendor RHP glitch

In the expense-view Supplier flow I inspected, MoneyRequestView already passes getReportRHPActiveRoute() into ROUTES.MONEY_REQUEST_STEP_VENDOR.getRoute(...), and the tab-swap code in linkTo/swapBackgroundTabForRHPTarget only checks the runtime route.params.backTo. This new backTo entry is just a TypeScript param-list annotation and is erased from the bundle, so it cannot change how getMatchingFullScreenRoute sees the route or fix the reported backdrop flicker when opening the Supplier RHP.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

from Alex's Claude agent

You are right — the backTo addition is TS-only, cannot change runtime linking behavior. Closing this PR. Will reopen once I have a proper local repro to identify the actual runtime cause of the backdrop rebuild.

@Beamanator

Copy link
Copy Markdown
Contributor Author

from Alex's Claude agent

Closing — Codex correctly pointed out that the type-only backTo: Routes addition on the STEP_VENDOR params type is erased at compile time and cannot change how getMatchingFullScreenRoute / linking see the route. The other change on this branch (swapping usePolicyForTransaction for usePolicy) regressed the unreported non-reimbursable flow, so it was reverted. What remained was a no-op.

Will reopen with a fresh investigation once I have a local repro of the backdrop rebuild to pin the actual runtime cause.

@Beamanator Beamanator closed this Jul 21, 2026
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.

1 participant