Skip to content

Fix blank Xero setup WebView on Android by loading an authenticated setup URL - #95552

Merged
neil-marcellini merged 3 commits into
Expensify:mainfrom
KJ21-ENG:KJ21-ENG/95199-android-xero-connect
Jul 14, 2026
Merged

neil-marcellini merged 3 commits into
Expensify:mainfrom
KJ21-ENG:KJ21-ENG/95199-android-xero-connect

Conversation

@KJ21-ENG

@KJ21-ENG KJ21-ENG commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

On Android, connecting a workspace to Xero opened a blank page (with a small "Pretty-print" toolbar) instead of the Xero authorization UI. The native Xero setup screen passed the raw getXeroSetupLink(policyID) value — the OldDot ConnectPolicyToXero command URL — straight into the AccountingSetupWebViewPage incognito WebView, which only supplied auth as a first-request Cookie header, so the WebView rendered the raw command response instead of an authenticated setup flow.

This PR makes the native Xero setup WebView load an authenticated URL, the same way other native OldDot handoffs (e.g. ConnectToHRFlow) do:

  • AccountingSetupWebViewPage gains an opt-in shouldAppendShortLivedAuthToken prop. When set, the page resolves getShortLivedAuthTokenURL(uri) before mounting the WebView and shows the existing loading indicator while the token request is in flight. If the token request fails while online, the helper falls back to the original link so the page does not hang in the loading state (the WebView then behaves as it did before this fix).
  • Like ConnectToHRFlow, the page skips the token request while offline and fetches it on reconnect (useNetwork({onReconnect}) with a fetch-once ref), so opening the page offline and then reconnecting still ends up on the authenticated URL.
  • The native XeroSetupPage passes shouldAppendShortLivedAuthToken, so its WebView now loads getXeroSetupLink(policyID) with a short-lived authToken appended and the Xero authorization UI renders.
  • QuickBooks Online also uses AccountingSetupWebViewPage but does not pass the new prop, so its setup WebView keeps mounting immediately with the unmodified uri — behavior there is unchanged by construction.
  • Unit tests, per the proposal: the native Xero setup test now mocks getShortLivedAuthTokenURL() and verifies the WebView receives the authenticated URL (not the raw getXeroSetupLink() value), that the loading indicator shows until it resolves, and that an offline mount defers the token request until reconnect. The QBO setup test now verifies the token helper is not called and the WebView mounts immediately with the raw setup link.

Fixed Issues

$ #95199
PROPOSAL: #95199 (comment)

Tests

  1. On Android native (and repeat once on iOS native, which shares this code path), sign in and open a workspace where you are an admin.
  2. Go to Workspace settings > More features and enable Accounting.
  3. Go to Accounting and tap Connect next to Xero.
  4. If prompted, complete the two-factor authentication setup flow and continue.
  5. Verify the in-app setup screen shows a loading spinner briefly and then loads the Xero sign-in/authorization page, instead of a blank page with a "Pretty-print" toolbar.
  6. Go back to Accounting and tap Connect next to QuickBooks Online. Verify the QuickBooks Online setup WebView still opens and loads as before (no regression from the shared component change).
  • Verify that no errors appear in the JS console

Offline tests

Connecting an accounting integration requires being online; the setup WebView is wrapped in FullPageOfflineBlockingView, which is unchanged. The short-lived token request is skipped while offline and retried on reconnect.

  1. Go offline, then open Workspace settings > Accounting and tap Connect next to Xero.
  2. Verify the full-page offline blocking view is shown instead of the setup WebView.
  3. While staying on the page, go back online. Verify the loading indicator appears and then the Xero sign-in/authorization page loads (the token request is made on reconnect).

QA Steps

  1. On Android native (staging), sign in and open a workspace where you are an admin.
  2. Go to Workspace settings > More features and enable Accounting.
  3. Go to Accounting and tap Connect next to Xero.
  4. If prompted, complete the two-factor authentication setup flow and continue.
  5. Verify the in-app setup screen loads the Xero sign-in/authorization page, instead of a blank page with a "Pretty-print" toolbar.
  6. Go back to Accounting and tap Connect next to QuickBooks Online. Verify the QuickBooks Online setup WebView still opens and loads as before.
  7. Repeat steps 3-5 once on iOS native, which shares this code path.

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 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 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.
  • 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

@KJ21-ENG
KJ21-ENG marked this pull request as ready for review July 8, 2026 18:50
@KJ21-ENG
KJ21-ENG requested review from a team as code owners July 8, 2026 18:50
@melvin-bot
melvin-bot Bot requested review from brunovjk and trjExpensify July 8, 2026 18:50
@melvin-bot

melvin-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

@brunovjk 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 request for a team and trjExpensify July 8, 2026 18:50
Comment thread src/pages/workspace/accounting/AccountingSetupWebViewPage.tsx Outdated
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
...ace/accounting/xero/XeroSetupPage/index.native.tsx 100.00% <ø> (ø)
...orkspace/accounting/AccountingSetupWebViewPage.tsx 96.55% <94.44%> (+2.80%) ⬆️
... and 137 files with indirect coverage changes

@brunovjk

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 982c80ca14

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

@brunovjk

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
95552_android_native.mov
Android: mWeb Chrome
iOS: HybridApp
95552_ios_native.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
95552_web_chrome.mov

@brunovjk brunovjk 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.

LGTM

@melvin-bot
melvin-bot Bot requested a review from neil-marcellini July 10, 2026 15:33

@neil-marcellini neil-marcellini 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.

Great work, especially on the automated tests!

@neil-marcellini
neil-marcellini merged commit 904e3bd into Expensify:main Jul 14, 2026
35 of 40 checks passed
@OSBotify

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.

@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/neil-marcellini in version: 9.4.34-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

Help site review — no changes required

I reviewed the changes in this PR against the help site files under App/docs/articles, and no help site updates are required.

Why: This is an internal bug fix. On Android/iOS native, connecting a workspace to Xero opened a blank page because the setup WebView loaded the raw getXeroSetupLink() command URL without authenticating it. The fix appends a short-lived auth token so the WebView loads the authenticated Xero authorization page — exactly the behavior the docs already describe. There are no new features, no changed UI labels/tabs/buttons, and no new user-facing steps.

The existing article already documents the intended (now-restored) flow:

  • New Expensify: Connect to Xero — step 7, "Log in to your Xero account to complete the connection," matches the WebView authorization step this PR fixes.
  • The Expensify Classic Xero article and the Xero troubleshooting/error articles are unaffected by this change.

Since the documented behavior is unchanged, there's nothing to add or correct, and I have not opened a draft docs PR.

Files changed in this PR (all code/tests — none user-facing docs)
  • src/pages/workspace/accounting/AccountingSetupWebViewPage.tsx — adds opt-in shouldAppendShortLivedAuthToken prop
  • src/pages/workspace/accounting/xero/XeroSetupPage/index.native.tsx — passes the new prop
  • tests/unit/components/XeroSetupPageTest.tsx, tests/unit/components/QuickbooksOnlineSetupPageTest.tsx — unit tests

⚠️ Note: browser-based verification was unavailable for this run, so this conclusion is based on static review of the diff and the help articles.

If you believe a doc should be added or updated (e.g., a mobile-specific note), reply with @MelvinBot and I'll draft it.

@KJ21-ENG, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review

@IuliiaHerets

Copy link
Copy Markdown

Hi @KJ21-ENG. The PR was failed by the QA team because, although Xero is working as expected, the original issue still occurs in QBO.

cc @neil-marcellini @brunovjk

1784056232509.WhatsApp_Video_2026-07-14_at_3.05.49_PM__1_.mp4

@KJ21-ENG

Copy link
Copy Markdown
Contributor Author

Thanks for testing. The QBO behavior shown here appears to be the existing issue tracked in #94142, not a regression introduced by this PR. The approved #95199 proposal is Xero-specific and explicitly allows the shared WebView change to be opt-in; accordingly, this PR intentionally leaves QBO unchanged and adds a regression test proving that behavior.
However, #94142 was later put on hold because work was proceeding through #95199.

@neil-marcellini @brunovjk, could you confirm whether you want #95552 formally expanded to cover #94142 as well? If so, I can update the implementation, tests, PR description, and linked fixed issues accordingly.

@brunovjk

Copy link
Copy Markdown
Contributor

Thanks for the summary KJ21-ENG. I’m fine with expanding #95552 to also address #94142 — the fixes could reasonably belong to the same scope, though keeping them separate is also acceptable if you prefer Neil. Thanks

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/roryabraham in version: 9.4.34-14 🚀

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/roryabraham in version: 9.4.34-14 🚀

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

Bundle Size Analysis (Sentry):

@KJ21-ENG

Copy link
Copy Markdown
Contributor Author

Thanks for the summary KJ21-ENG. I’m fine with expanding #95552 to also address #94142 — the fixes could reasonably belong to the same scope, though keeping them separate is also acceptable if you prefer Neil. Thanks

Waiting for @neil-marcellini On this. Thanks!

@aimane-chnaif

aimane-chnaif commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

To be fair, I suggest to fix QBO issue separately as issue was already created before #95199 (which this PR fixes) and proposals were reviewed.
And happening on different pages.

cc: @neil-marcellini

@neil-marcellini

Copy link
Copy Markdown
Contributor

To be fair, I suggest to fix QBO issue separately as issue was already created before #95199 (which this PR fixes) and proposals were reviewed. And happening on different pages.

cc: @neil-marcellini

Sounds good, go for it!

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.

7 participants