Skip to content

Focus Address line 1 when the home address link opens private personal details - #100315

Merged
iwiznia merged 9 commits into
mainfrom
claude-focusAddressLine1FromHomeAddressLink
Oct 6, 2026
Merged

iwiznia merged 9 commits into
mainfrom
claude-focusAddressLine1FromHomeAddressLink

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Fixed Issues

$ #100235
PROPOSAL: #100235 (comment)

Tests

  1. Create a workspace and add an address to workspace.
  2. Enable Distance rates. Select Calculate by home and office in Distance rates > Settings > Exclude commutes.
  3. Invite another member to the workspace.
  4. Log in as the invited member
  5. Go to invited workspace chat.
  6. Click Add address button → Address line 1 field is auto focused.
  7. Go back to invited workspace chat.
  8. Click home address link.
  9. Confirm Address line 1 is auto focused when opened from home address link.
  • Verify that no errors appear in the JS console

Offline tests

None

The change is a pure string rewrite of already-rendered report action HTML, so behavior is unchanged offline.

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

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

…rsonal details

Co-authored-by: Alberto Gonzalez-Cela <Gonals@users.noreply.github.com>
@MelvinBot
MelvinBot requested a review from a team September 3, 2026 15:26
@melvin-bot melvin-bot Bot added Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web labels Sep 3, 2026
@codecov

codecov Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
...port/actionContents/HomeAddressRequiredContent.tsx 100.00% <100.00%> (ø)
... and 9 files with indirect coverage changes

…ed group

Co-authored-by: Alberto Gonzalez-Cela <Gonals@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Two checks were failing for two unrelated reasons. I pushed a fix for the one that belongs to this PR and left the other alone, because it is already broken on main.

Fixed: Oxfmt check

The new htmlparser2 import landed inside the react-native-onyx type-import block. .oxfmtrc.json puts type-import in its own sorted group before external value imports, so oxfmt --write wanted them split. Pushed in 5eedcb5:

-import {DomUtils, parseDocument} from 'htmlparser2';
 import type {OnyxEntry} from 'react-native-onyx';
+
+import {DomUtils, parseDocument} from 'htmlparser2';

No behavior change — import order only. See src/pages/inbox/report/actionContents/HomeAddressRequiredContent.tsx:21-23.

Not fixed: typecheck — already broken on main

src/hooks/useTransactionInlineEdit.ts(98,32): error TS2304: Cannot find name 'originalUseOnyx'.
src/hooks/useTransactionInlineEdit.ts(100,32): error TS2304: Cannot find name 'originalUseOnyx'.
src/hooks/useTransactionInlineEdit.ts(132,43): error TS2304: Cannot find name 'originalUseOnyx'.

This PR does not touch that file — git diff origin/main HEAD -- src/hooks/useTransactionInlineEdit.ts is empty. main itself does not typecheck, so this PR cannot go green until main is fixed.

It is a semantic merge conflict, not a bad merge: commit 4becd4f4 renamed the alias to useOnyxWithoutSnapshots app-wide, then #99279 merged (c408634c, today 14:45 UTC) off a base that predated the rename and reintroduced three originalUseOnyx call sites. Git merged cleanly; the compiler did not. The import at src/hooks/useTransactionInlineEdit.ts:33 now only binds useOnyxWithoutSnapshots, while lines 98, 100, and 132 still call the old name. The one-line fix on main is renaming those three call sites.

Check independent approval also fails, which is expected on an unapproved PR.

Local verification after the fix
Check Result
npm run fmt ✅ no files rewritten
npx eslint src/pages/inbox/report/actionContents/HomeAddressRequiredContent.tsx ✅ pass
npm test -- --silent tests/unit/HomeAddressRequiredContentTest.tsx ✅ 3 passed
npm run react-compiler-compliance-check check src/pages/inbox/report/actionContents/HomeAddressRequiredContent.tsx ✅ pass
npm run typecheck ❌ same 3 pre-existing main errors, nothing new

npm run lint-changed could not run here — it needs a git merge-base against origin/main, which the shallow CI clone does not have. I ran eslint on the changed file directly instead.


view run

@MelvinBot

MelvinBot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Android test steps verification results: ⚠️ partial

The documented steps could not be run end-to-end: the setup requires Distance rates > Settings > Exclude commutes, which is gated behind the commuterExclusions beta that the Melvin test account doesn't have — so Concierge never posts the home-address-required message and neither entry point exists to tap. Instead I verified the destination side of the fix directly on Android via deep links: the fieldToFocus=addressLine1 route focuses Address line 1 with the keyboard up, and the bare route focuses nothing. That confirms the param-vs-bare-route difference this PR hinges on, but not the link rewrite itself in the chat.

Personal details opened on bare route; nothing focused

Step Status
SETUP: create workspace, add company addressOnboarding auto-created a workspace; Overview > Company address saved and read back as "123 Main Street, Broomfield, CO 80020".
✅
SETUP: enable Distance ratesDistance rates selected during onboarding and confirmed active in Workspace > Distance rates (Default Rate, Active, $0.76/mile).
✅
SETUP: Distance rates > Settings > Exclude commutes > Calculate by home and officeThe Settings page has no "Exclude commutes" row for this account. Both the row and its destination page are gated behind the commuterExclusions beta — PolicyDistanceRatesSettingsPage.tsx:79 and PolicyCommuterExclusionsPage.tsx:216-220. No UI or deep-link path completes this step from the client.
Distance rates Settings page with no Exclude commutes row
❌
Tap "Add address" button → Address line 1 auto-focusedNot reachable — the workspace never entered the commuter-exclusions "home and office" state needed for Concierge to post the HOMEADDRESSREQUIRED message.
❌
Tap "home address" link → Address line 1 auto-focusedNot reachable — same blocker.
❌
No JS console / redbox errors during the flowNot verifiable — the in-chat flow was never reached. No redbox appeared during the parts that did run.
❌
Substitute: deep link to private-personal-details?fieldToFocus=addressLine1 auto-focuses Address line 1new-expensify://settings/profile/private-personal-details?fieldToFocus=addressLine1 opened Personal details on the Home address section. The Address line 1 field reported focused: true and the soft keyboard was up (mInputShown=true) immediately after navigation, with no other action taken.
Personal details opened with fieldToFocus=addressLine1; Address line 1 focused
✅
Substitute: deep link to the bare route leaves nothing focusednew-expensify://settings/profile/private-personal-details (no param) opened the same page with no focused node anywhere and no keyboard (mInputShown=false) — the pre-fix behavior of the "home address" link.
Personal details opened on bare route; nothing focused
✅

To fully verify the documented steps on Android, grant the commuterExclusions beta to a test account (or run these on an account that already has it) and re-run.


view run · view recording

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Oxfmt check is green now — that was the only failure belonging to this PR, and I fixed it in 5eedcb5 earlier.

Everything still red is one pre-existing bug on main, and a fix PR is already open: #100314. Nothing further to push here.

The two remaining failures are the same root cause

main is missing the binding for originalUseOnyx in src/hooks/useTransactionInlineEdit.ts. That single unresolved name produces both failures:

  • typecheck — TS2304: Cannot find name 'originalUseOnyx' at lines 98, 100, and 132. It is the only TS error in the whole run.
  • ESLint check — 9 errors, all no-unsafe-assignment / no-unsafe-call in that same file at lines 98, 100, 101, 132, 199, 201. Because the name doesn't resolve, its type is error, and every read of it trips the unsafe-* rules. Downstream noise from the same missing binding.

This PR does not touch that file — git diff origin/main HEAD -- src/hooks/useTransactionInlineEdit.ts is empty — so I can't fix it from this branch without pulling in unrelated changes.

main itself does not lint or typecheck, so no PR can go green until #100314 lands. It is open, mergeable, and rewrites exactly those three call sites to useOnyxWithoutSnapshots. Once it merges, re-run these two checks here and they should pass untouched.

Check independent approval also fails, which is expected on an unapproved PR.

Why `main` broke

A semantic merge conflict, not a bad merge. Commit 4becd4f4 renamed the alias to useOnyxWithoutSnapshots app-wide. #99279 then merged (c408634c, 14:45 UTC) off a base predating that rename and reintroduced three originalUseOnyx call sites. Git merged cleanly; the compiler and linter did not. The import at src/hooks/useTransactionInlineEdit.ts:33 now only binds the new name.

I did not merge main into this branch — main's current HEAD (ea45c1c) is still broken, so it would not have helped.


view run

@MelvinBot

Copy link
Copy Markdown
Contributor Author

No code fix to push — every automated check passes. The two remaining failures are human gates, not code problems.

Failing check Why it fails Who unblocks it
checklist (PR Author Checklist) You completed 0 out of 38 checklist items with 38 unfinished items You — the boxes attest a human thought about each item, so I won't tick them for you
Check independent approval The Verify peer review step fails: no independent reviewer has approved yet A reviewer other than the author

Everything else is green on the latest commit, including all 8 Jest shards, typecheck, ESLint check, Oxfmt check, React Compiler Compliance, spellcheck, Bun tests, Storybook tests, Knip check, and both iOS and Android builds. The TypeScript Checks failure from the 3 Sep run is gone — typecheck now passes in 1m3s.

Two things in the PR body still need you before the checklist can pass:

  1. The Tests and QA Steps sections are still // TODO: **The human co-author** must fill out... placeholders.
  2. The 38 author-checklist boxes are all unchecked.

I deliberately left both alone. Filling in test steps or checking attestation boxes on your behalf would make the checklist assert verification that never happened.

@Expensify Expensify deleted a comment from MelvinBot Sep 7, 2026
@Expensify Expensify deleted a comment from MelvinBot Sep 7, 2026
@Gonals
Gonals marked this pull request as ready for review September 7, 2026 11:43
@Gonals
Gonals requested a review from a team as a code owner September 7, 2026 11:44
@melvin-bot
melvin-bot Bot requested review from getusha and joekaufmanexpensify and removed request for a team September 7, 2026 11:44
@melvin-bot

melvin-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

@getusha 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 removed the request for review from a team September 7, 2026 11:44

@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: e2f484be8d

ℹ️ 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".

@Gonals
Gonals requested a review from a team as a code owner September 7, 2026 11:57
@melvin-bot
melvin-bot Bot requested review from Gonals and iwiznia and removed request for a team September 7, 2026 11:57

@joekaufmanexpensify joekaufmanexpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good for product.

@Gonals

Gonals commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Quick bump, @iwiznia

@getusha

getusha commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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 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.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp

N/a

Android: mWeb Chrome Screenshot_1789721647
iOS: HybridApp

N/a

iOS: mWeb Safari

N/A

MacOS: Chrome / Safari
Screen.Recording.2026-09-18.at.11.34.15.AM.mov

// The backend links to the private personal details page without a field to focus, so point the link at
// Address line 1
const messageHtml = (getReportActionHtml(action) || getReportActionText(action)).replaceAll(
ROUTES.SETTINGS_PRIVATE_PERSONAL_DETAILS.route,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@MelvinBot shouldn't we have a link based on the environment here? ${environmentURL}/$

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.

Not for the focus param itself — but yes, this HTML does need the environment treatment, and right now it doesn't get it.

Why the replaceAll doesn't need environmentURL: it replaces only the path substring, so whatever origin the backend baked in is left intact — HomeAddressRequiredContent.tsx:39-41. Prefixing ${environmentURL}/ here would build a second, absolute URL and break the match.

What is missing: the backend bakes https://new.expensify.com into report action HTML, and this component renders it without passing it through adjustExpensifyLinksForEnv (the only caller today is TextCommentFragment.tsx:106). In-app navigation requires the href origin to match the current environment (Link.ts:394, Link.ts:435-437), so on dev/staging the click falls through to openExternalLink and opens production in a new tab — the autofocus never runs where QA tests it.

Suggested change — reuse the existing helper instead of hand-building the URL:

const {adjustExpensifyLinksForEnv} = useEnvironmentActions();

const messageHtml = adjustExpensifyLinksForEnv(getReportActionHtml(action) || getReportActionText(action)).replaceAll(
    ROUTES.SETTINGS_PRIVATE_PERSONAL_DETAILS.route,
    ROUTES.SETTINGS_PRIVATE_PERSONAL_DETAILS.getRoute(INPUT_IDS.ADDRESS_LINE_1),
);
Supporting detail
  • adjustExpensifyLinksForEnv rewrites only the origin and handles all three href quoting styles; it exists precisely because staging and production share one report-action table, so the stored origin is wrong for one of them — see the doc comment at EnvironmentContextProvider/index.tsx:31-43.
  • Order doesn't matter: the origin rewrite keys off the origin prefix, the focus rewrite off the path, so the two passes don't interfere.
  • The ?fieldToFocus= param does survive internal navigation — getPathFromURL keeps search (Url.ts:18-27) — and is read at PrivatePersonalDetailsPage.tsx:54.
  • Unrelated nit on the same line: replaceAll on the bare path also matches the longer route settings/profile/private-personal-details/confirm, producing ...private-personal-details?fieldToFocus=addressLine1/confirm. Harmless today since the backend doesn't link there, but anchoring the match to the end of the path would make it safe.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@MelvinBot any reason we shouldn't? can you apply the change if none?

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.

No reason not to — it's a two-line change and it can't regress production, since adjustExpensifyLinksForEnv returns the HTML untouched when the current environment already is production.

+import {useEnvironmentActions} from '@components/EnvironmentContextProvider';

 function HomeAddressRequiredContent({action}: HomeAddressRequiredContentProps) {
     const {translate} = useLocalize();
+    const {adjustExpensifyLinksForEnv} = useEnvironmentActions();

-    const messageHtml = (getReportActionHtml(action) || getReportActionText(action)).replaceAll(
+    const messageHtml = adjustExpensifyLinksForEnv(getReportActionHtml(action) || getReportActionText(action)).replaceAll(
         ROUTES.SETTINGS_PRIVATE_PERSONAL_DETAILS.route,
         ROUTES.SETTINGS_PRIVATE_PERSONAL_DETAILS.getRoute(INPUT_IDS.ADDRESS_LINE_1),
     );

I checked the things that could have been a reason to skip it, and none of them are:

  • Existing tests keep passing. HomeAddressRequiredContentTest.tsx renders the component without an EnvironmentProvider, so useEnvironmentActions() resolves to the default context whose implementation is the identity function (default.ts:13) and the existing new.expensify.com assertions are unchanged.
  • Order of the two rewrites doesn't matter. The env pass keys off the origin prefix, the focus pass off the path, so they don't interfere.
  • No duplication concern. It reuses the existing helper rather than adding a second href-rewriting mechanism, which is what the earlier CONSISTENCY-3 comment on this thread was about.

One caveat on scope: this is a pre-existing bug, not one this PR introduced — the link has always pointed at production outside production. Folding it in here is only worth it because the PR's whole point (autofocus) is untestable on dev/staging without it.

I can only make code changes when directed by the PR author, an assignee, or an existing co-author. Gonals — want me to apply this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yeah an issue only on dev and staging, it's fine if we leave it like this too
cc @Gonals

@getusha

getusha commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot what's the reason it opens the link in a browser on native instead of just navigating to the page

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Because in-app navigation is gated on the link's origin matching the build you're running, and the stored href is always the production origin. That check fails on an ad-hoc/staging/dev native build, so the link is treated as an external URL — and on native "external" means Linking.openURL, i.e. the device browser.

It isn't native-specific logic. The same branch runs on web, but there "external" is just a new tab, so it looks much less wrong.

The chain:

  1. The anchor press calls openLink, which computes hasSameOrigin against the current environmentURL — Link.ts:394.
  2. In-app navigation requires both an internal NewDot path and that origin match — Link.ts:435-437. The path resolves fine (production is in NEW_EXPENSIFY_ORIGINS, Link.ts:155-168), but the origin doesn't.
  3. So it falls through to openExternalLink → Link.ts:83-85 → asyncOpenURL/index.ts:15, which is Linking.openURL — the system browser.

Why your native build trips it: ad-hoc builds resolve to the staging URL (Environment.ts:15), so staging.new.expensify.com ≠ new.expensify.com in the href. A production native build matches and does navigate in-app — consistent with this being a dev/staging-only problem.

Applying adjustExpensifyLinksForEnv fixes exactly this: it rewrites the origin to the current environment, hasSameOrigin then passes, and native navigates to the page in-app instead of opening the browser.

On the origin check itself

The gate is old (it predates the 2023 TS migration, so blame only shows refactor commits) and carries no comment explaining the choice, so I can't quote a documented rationale. Mechanically it means the app treats a link pointing at a different deployment as external rather than following it in-app — which is reasonable, since navigating a production link inside a staging build would render that route against staging data.

One native detail worth knowing: if openLink were never reached, AnchorForCommentsOnly/index.native.tsx:13 also falls back to Linking.openURL(href). That isn't what's happening here — onPress is set because the path does resolve as internal (AnchorRenderer.tsx:60-66) — but it's the second place a mismatched link ends up in the browser on native.

@getusha

getusha commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Oh ok it's the same issue as #100315 (comment)

@melvin-bot
melvin-bot Bot requested a review from iwiznia October 6, 2026 07:08
@Gonals

Gonals commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

All yours @iwiznia

@iwiznia
iwiznia merged commit 9091d66 into main Oct 6, 2026
49 of 51 checks passed
@iwiznia
iwiznia deleted the claude-focusAddressLine1FromHomeAddressLink branch October 6, 2026 14:15
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🚧 iwiznia has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

OSBotify commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify OSBotify mentioned this pull request Oct 6, 2026
100 tasks done
@OSBotify

OSBotify commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/iwiznia in version: 9.5.4-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor Author

No help site update needed. This PR only auto-focuses the Address line 1 field when the home address link is opened, a small UX fix that doesn't change any step or sentence in an existing help article.


view run

@mitarachim

Copy link
Copy Markdown

Deploy Blocker #103266 was identified to be related to this PR.

@OSBotify

OSBotify commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 9.5.4-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@OSBotify

OSBotify commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/iwiznia in version: 9.5.5-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor Author

No help site update needed. This PR only auto-focuses the Address line 1 field when the home address link is opened, a small UX fix that doesn't make any step or sentence in an existing help article incorrect.


view run

@OSBotify

OSBotify commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 9.5.5-2 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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

Labels

Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants