Repository navigation
Conversation
The lazy connections fetch is gated on policyHasConnectionsDataBeenFetched_<policyID>, which is set write-once and never invalidated. A connection created after that fetch — Xero setup runs outside NewDot — is therefore invisible to the client until a manual re-sync, so the Vendors switch on More features stays locked OFF. Mark the policy's connections stale at each Xero handoff and re-read them when the app or the screen regains focus. Both triggers are needed: on web the setup opens OldDot in a separate browser tab so only window focus fires, while on native it runs in an in-app WebView so the app never backgrounds and only screen focus fires. The marker is a deadline rather than a one-shot flag because the sync the setup starts is asynchronous. A single refresh can land before the sync does, and consuming the marker there would strand the stale value exactly as before. Co-authored-by: Chuck Dries <chuckdries@users.noreply.github.com>
|
🤖 Web test steps verification results: Reached More features on a newly-created workspace on PR branch No console errors were captured during the run. What a real verification needs: a pre-provisioned workspace with a completed Xero OAuth connection, plus the view run · no recording available |
…props in the 2FA success test The Onyx key export coverage test requires every ONYXKEYS.COLLECTION value to sit in an export bucket. policyConnectionsRefreshDeadline_ holds only a timestamp, so it goes in safeOnyxKeys next to policyHasConnectionsDataBeenFetched_. DynamicSuccessPage takes the full PlatformStackScreenProps, so the test has to supply navigation as well as route. Co-authored-by: Chuck Dries <chuckdries@users.noreply.github.com>
|
Both real failures were caused by this PR. Fixed and pushed in
Verified locally on the pushed commit
|
|
🤖 Android test steps verification results: Reached More features on the account's only workspace at PR head
The tester also completed first-run onboarding (purpose selection, name entry, work-email skip) to reach a usable Home state, since CI handed over a brand-new account. No console errors were captured. What a real verification needs: a workspace pre-seeded with a completed Xero OAuth connection, plus the |
|
@MelvinBot Could you please assign this PR to me? |
|
Done — you're now assigned to this PR alongside |
| return; | ||
| } | ||
| // The connection this produces is created outside NewDot, so the lazily-fetched policy.connections copy | ||
| // this client already holds can't see it. Mark it stale before handing off so it gets re-read on return. |
There was a problem hiding this comment.
@MelvinBot Could you remove this comment? The field name is self-explanatory, so I don't think we need a comment here.
| return; | ||
| } | ||
| // The connection this produces is created outside NewDot, so the lazily-fetched policy.connections copy | ||
| // this client already holds can't see it. Mark it stale before handing off so it gets re-read on return. |
There was a problem hiding this comment.
@MelvinBot Could you remove this comment? The field name is self-explanatory, so I don't think we need a comment here.
| // How long after an external accounting setup handoff NewDot keeps re-reading the policy's | ||
| // connection config on focus. The setup runs outside NewDot and the sync it starts is | ||
| // asynchronous, so the client has to keep looking for a while rather than refreshing once. |
There was a problem hiding this comment.
@MelvinBot Could you remove this comment? The field name is self-explanatory, so I don't think we need a comment here.
| // The lazy fetch above runs at most once per policy per device, so it can't pick up a connection that was | ||
| // created after it ran. `markPolicyConnectionsAsStale` marks that case, and the refresh below is what | ||
| // actually re-reads the config. | ||
| // | ||
| // The only flow that sets the marker today is the Xero setup handoff, and the field that handoff is | ||
| // expected to produce is `xero.config.isConfigured` — the same field the Vendors toggle reads. Checking it | ||
| // directly is what lets the marker survive a refresh that lands while the sync is still running, instead of | ||
| // clearing on the first response and stranding the stale value. |
There was a problem hiding this comment.
@MelvinBot Could you remove this comment? The field name is self-explanatory, so I don't think we need a comment here.
| // Two triggers, because neither one covers both platforms. On web the setup opens OldDot in a separate | ||
| // browser tab, so the user comes back to an already-mounted screen and only the window focus event fires. | ||
| // On native the setup runs in an in-app WebView, so the app is never backgrounded and `AppState` never | ||
| // leaves `active` — there the screen regaining focus is the only signal. |
There was a problem hiding this comment.
@MelvinBot Could you remove this comment? The field name is self-explanatory, so I don't think we need a comment here.
| /** | ||
| * Marks a policy's connection data as stale for a bounded window, so `usePolicyConnectionsPrefetch` re-reads | ||
| * it the next time the app or the screen regains focus. | ||
| * | ||
| * Call this whenever NewDot hands the user off to an external accounting setup flow. `openPolicyAccountingPage` | ||
| * sets `policyHasConnectionsDataBeenFetched_<policyID>` write-once and nothing invalidates it, so without this | ||
| * marker the client keeps serving the copy it fetched *before* the connection existed and never picks up the | ||
| * config that the setup produces. | ||
| * | ||
| * This is a deadline rather than a one-shot flag on purpose. The sync the setup starts is asynchronous, so the | ||
| * user can be back in NewDot before it lands; a one-shot refresh would then read a connection that is still not | ||
| * configured, consume itself, and leave the stale value in place until a manual re-sync. It also makes the | ||
| * marker immune to the refetch that the still-mounted screen fires the moment it is set — that read is simply | ||
| * one of several attempts within the window rather than the only one. | ||
| */ |
There was a problem hiding this comment.
@MelvinBot Could you remove this comment? The field name is self-explanatory, so I don't think we need a comment here.
| Onyx.set(`${ONYXKEYS.COLLECTION.POLICY_CONNECTIONS_REFRESH_DEADLINE}${policyID}`, Date.now() + CONST.POLICY.CONNECTIONS.REFRESH_AFTER_SETUP_WINDOW_MS); | ||
| } | ||
|
|
||
| /** Drops the stale marker set by `markPolicyConnectionsAsStale`, once the refresh has served its purpose or its window has passed. */ |
There was a problem hiding this comment.
@MelvinBot Could you remove this comment? The field name is self-explanatory, so I don't think we need a comment here.
| // This path bypasses ConnectToXeroFlow, so it has to mark the connections stale itself — otherwise | ||
| // users who set up 2FA as part of connecting Xero keep the pre-connection policy.connections copy. |
There was a problem hiding this comment.
@MelvinBot Could you remove this comment? The field name is self-explanatory, so I don't think we need a comment here.
| // Deadline (epoch ms) until which the policy's connection data is treated as stale and re-read | ||
| // whenever the app or the screen regains focus. Set when NewDot hands the user off to an external | ||
| // accounting setup flow. Like the flag above this is client-only state, so it lives outside the | ||
| // policy object. |
There was a problem hiding this comment.
@MelvinBot Could you remove this comment? The field name is self-explanatory, so I don't think we need a comment here.
Co-authored-by: huult <huult@users.noreply.github.com>
|
Removed all nine commented blocks you flagged in 091dc83, and replied in each thread.
One thing worth your call: the Checks run
view run · no recording available |
|
There is nothing to fix in the code — the only failing check is waiting on a human.
Every code check passes on the current head: typecheck, ESLint, Oxfmt, spellcheck, React Compiler compliance, all 8 Full check status
Relevant log lines from the failing run: I did not push anything, since no code change would clear this check. |
|
Nothing is broken in the code — there's no fix to push. Both failing checks are human-process gates waiting on a reviewer:
Every code check passes on the current commit: To go green: |
|
@Beamanator After the Xero OAuth completes, does the backend automatically trigger a sync immediately (either synchronously or via a high-priority queue), or does it only enable autoSync.enabled=true and wait for the next scheduled sync cycle? |
It looks like we automatically trigger a sync immediately when the oauth flow originated from NewDot - https://github.com/Expensify/Web-Expensify/blob/cf68a16343bd9482525012c128ca01d6877c8c44/partners/xero/oauth_callback.php#L128 |
Screen.Recording.2026-09-07.at.11.26.18.mov@Beamanator I can't access the backend source. Could you check why Pusher doesn't immediately update |
|
@Beamanator I think we need to update the backend based on this. Could you check it and help me update it? |
|
@MelvinBot Could you resolve the conflict? |
Resolves conflict in src/libs/actions/PolicyConnections.ts: main added openPolicyRecruitingPage to the export list while this branch added the connections stale-marker helpers. Kept both.
|
Conflict resolved and pushed — the PR is mergeable again. There was one conflict, in export {openPolicyAccountingPage, openPolicyHRPage, openPolicyRecruitingPage, updateConnectionConfig, markPolicyConnectionsAsStale, clearPolicyConnectionsStaleMarker};Merged with VerificationThree other files this PR touches were also changed on
Checks run locally on the merge commit:
Suites run: Could not run:
view run · no recording available |
|
yeah interesting, i think you're right so i made a PR to get that fix up sir 👍 |
thank you 😄 |
|
got the fix merged, not deployed yet 😬 |
Thank you! Tag me when it’s ready. I’ll retest it and continue checking this PR. |
|
@huult deployed! Check again when you have time plz 🙏 |
|
@MelvinBot could you sync with main? |
…sRefresh Co-authored-by: huult <huult@users.noreply.github.com>
Screen.Recording.2026-09-12.at.22.31.20.movIt’s working, thanks! |
|
MelvinBot has made 5 consecutive commits trying to fix CI failures. Automatic CI fix dispatches are now paused for this PR. Next steps: A human should review the recent commits and resolve the conflicting CI errors manually. |
|
🤖 Synced with The branch was 1545 commits behind. The merge was conflict-free and Details
|
@MelvinBot The issue is gone after we fixed it on the backend side, so I don't think we need this PR anymore, right? |
|
🤖 Agreed — close it. The backend fix removes the cause; this PR was only a client-side workaround for it, and you've confirmed the bug is gone. One thing to confirm with Confirm: does the connections push carry an Even if that gap is real, this PR isn't the right shape for it. The underlying defect is that Correction for the record: the PR description's web justification was wrong. It claimed "Pusher updates are dropped by non-leader tabs — which is exactly the web case, since the handoff opens a second tab." The setup tab is OldDot on a different origin, so it never joins NewDot's leader election and can't demote the NewDot tab. Backgrounding alone never demotes either, and nothing unsubscribes Pusher on blur. Evidence for the leader-election correction
|
|
@MelvinBot please close this PR |
|
🤖 Closed this PR as requested. The branch view run · no recording available |




Explanation of Change
The Vendors switch on Workspace > More features stays locked OFF after connecting Xero, and only flips ON after a manual "Sync now".
NewDot lazy-loads
policy.connectionsbehindpolicyHasConnectionsDataBeenFetched_<policyID>, whichopenPolicyAccountingPagesets write-once with no invalidation path. Xero setup runs outside NewDot (OldDot in a browser tab on web, an in-app WebView on native), so the connection is created after that flag was already set — the client keeps serving the copy it fetched before the connection existed. The switch readsisXeroVendorMatchingActive→policy.connections.xero.config.isConfigured, a server-only field, so it renders visible but OFF.SyncPolicyToXeroreturns fresh connections in its read response, which is why a manual re-sync is currently the only repair.This adds a bounded "connections are stale" marker set at each Xero handoff, and re-reads the config when the app or the screen regains focus.
Two details worth calling out for review:
Both focus triggers are needed — they are not redundant. On web the setup opens OldDot in a separate browser tab, so the user returns to an already-mounted screen and only the window focus event fires. On native the setup runs in an in-app
WebView, so the app is never backgrounded,AppStatenever leavesactive, anduseAppFocusEventnever fires — there the screen regaining focus is the only signal. Each platform's blind spot is the other's signal.The marker is a deadline, not a one-shot flag. The sync the setup starts is asynchronous, so a refresh can land before the sync does. Consuming the marker on that first response would clear it while
isConfiguredis still false and strand the stale value exactly as before — reproducing the reported bug. Instead the marker is cleared only once the connection reportsisConfigured, or once its 15-minute window passes. This also makes the marker immune to the refetch the still-mounted screen fires the moment it is set: that read is just one of several attempts in the window rather than the only one.What this deliberately does not do, per the approved proposal: it does not remove the
config.isConfiguredpredicate (it guards against selecting stale contacts during a Xero tenant switch), does not gate row visibility onhasVendorFeature, does not setisConfiguredoptimistically, and does not refetch unconditionally on every mount. A connection that is genuinely still syncing or failed still renders OFF, which is correct.Scoping note: the stale-flag semantics affect every
usePolicyConnectionsPrefetchconsumer, but the marker is only set by the Xero setup handoff, so routine network traffic is unchanged.Follow-up worth considering separately:
policyConnectionSyncProgress_<policyID>receives server-pushed stage updates and would be a truer "the server now has fresh config" trigger than focus. It was left out here to keep the change scoped, and because Pusher updates are dropped by non-leader tabs — which is exactly the web case, since the handoff opens a second tab.Fixed Issues
$ #99986
PROPOSAL: #99986 (comment)
Tests
// TODO: The human co-author must fill out the tests you ran before marking this PR as "ready for review".
// Please describe what tests you performed that validate your change worked.
// Note: reproducing this needs a real Xero OAuth connection plus the
vendorMatchingbeta, so it could not be automated.Offline tests
The refresh is skipped entirely while offline —
usePolicyConnectionsPrefetchreturns early onisOffline, and the stale marker is left in place so the re-read happens on the next focus after reconnecting. This is covered by an automated test (does not refresh while offline).QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
// The human co-author must fill out the QA steps before marking this PR as "ready for review".
// Please describe what QA needs to do to validate your changes and what areas they need to test for regressions.
AI Tests
Run locally by MelvinBot on this branch:
npm run typechecknpm run lint-changednpm run spell-changednpm run react-compiler-compliance-check check <changed files>npm test— 9 affected suitesnpm test tests/unit/hooks— all hook suitesAffected suites run:
usePolicyConnectionsPrefetch.test.ts(new),DynamicSuccessPageTest.tsx(new),ConnectToXeroFlowTest.tsx,ConnectToXeroFlowWebTest.tsx,WorkspaceMoreFeaturesPageTest.tsx,PolicyUtilsTest.ts,PolicyConnectionsTest.ts,WorkspaceInitialPageTest.tsx,ProductMarketingWindowTest.tsx.Could not run:
npm testsuite — exceeded the 10-minute local command cap. All hook suites were run instead, since the change touches a shared hook. CI runs the full suite.npm run prettier— no such script exists inpackage.jsonat this commit; formatting is enforced throughnpm run lint-changed.npm run storybook -- --smoke-test --ci— not run; no Storybook stories are touched by this change.New regression coverage added:
isConfiguredis true, and once the window passes.PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari