You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Gusto - Can't connect to Gusto an error appear #101727
⚠️Confidence: Medium. The App-side chain is confirmed in code. The root cause sits in a backend repo (Auth/Web-Expensify) that I can't read from this environment, so the backend mechanism below is inferred, not verified against source or logs.
What is the root cause of that problem?
The failure is server-side. App is only the messenger.
The string 401 Approval workflow rules manage this policy's approval flow does not exist anywhere in Expensify/App (grep -rn "Approval workflow rules" src/ → 0 hits). It arrives from the backend in policy.connections.gusto.lastSync.errorMessage, and App concatenates it verbatim into the card's error text:
That reproduces the reported string character for character.
App sends no approval-related parameter when connecting. ConnectPolicyToGustoParams is {policyID} only, and getGustoSetupLink just opens that URL in the browser. So the approval-mode write that gets rejected happens entirely on the server during (or right after) ConnectPolicyToGusto.
Why it collides: a Gusto HR connection takes over the workspace's approval flow — when its mode is BASIC or MANAGER, App makes the whole Workflows tab read-only (HRUtils.ts:83-97). The Applause Gusto (DO NOT DELETE) workspace already has approval workflow rules configured, so the backend's attempt to hand approvals to Gusto is blocked by the approval-workflow guard, which returns jsonCode 401 with that message.
What changes do you think we should make in order to solve the problem?
The fix is not in this repo.ConnectPolicyToGusto needs to stop attempting an approval-mode write that conflicts with the policy's existing approvalRules — either connect first and let the admin choose the mode afterwards (the CUSTOM option already exists at CONST/index.ts:3351-3357), or clear/override the conflicting rules as part of connecting. This needs an internal engineer with Auth/Web-Expensify access.
Two genuine but secondary App-side problems, worth fixing regardless of the backend outcome:
Raw backend error leaks into user copy.MergeProviderCard.tsx:87 interpolates an arbitrary server string, jsonCode prefix and all. Strip the numeric code or map known codes to real copy.
No pre-flight check.handleConnect validates only the setup link, write access, and "another HR provider is connected" — it never looks at policy.rules.approvalRules, despite hasConfiguredRules already existing. A confirm modal here would mirror the existing "Change approval mode?" prompt at HRApprovalModePageBase.tsx:101-117.
What alternative solutions did you explore?
Alternatives considered and why they were ruled out
A real Gusto OAuth 401. Ruled out. lastSync.isAuthenticationError is false — otherwise MergeProviderCard.tsx:73-84 would have rendered the authenticationError copy with a Reconnect link instead. The message text is also Expensify-internal policy language, not anything Gusto would emit. The 401 is a jsonCode embedded in the message body, not an auth failure.
App sending a bad approvalMode during connect. Ruled out — the connect params are {policyID} only, and UpdateGustoApprovalMode / UpdateGustoFinalApprover fire only from the dedicated settings pages, which are gated behind state.isConnected (hr/utils.ts:218-238).
Error originating from a post-connect sync rather than connect itself. Cannot be distinguished from App — both write to lastSync. Worth checking on the backend side, since it changes where the guard needs relaxing.
What I could not verify: VictoriaLogs was unavailable in this run, so there is no production confirmation of frequency or blast radius (does this hit every workspace with approval rules, or only this one?). Reproducing in a test session also isn't possible without the Applause tester account and live Gusto credentials.
Related issues: I scanned open Expensify/App issues for Gusto connect failures and found no duplicate.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/101727) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
@Gonals@FitseTLT this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
Activity
applause-bot commentedon Sep 21, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/ab640d6cb5e92487d5cd41678a1bd0c48b182e7df111e5848ae07047dc8f13e4
MelvinBot commentedon Sep 21, 2026
Proposal
What is the root cause of that problem?
The failure is server-side. App is only the messenger.
The string
401 Approval workflow rules manage this policy's approval flowdoes not exist anywhere inExpensify/App(grep -rn "Approval workflow rules" src/→ 0 hits). It arrives from the backend inpolicy.connections.gusto.lastSync.errorMessage, and App concatenates it verbatim into the card's error text:src/pages/workspace/merge/MergeProviderCard.tsx:85-87—`${genericError} ("${card.lastSyncErrorMessage}")`src/languages/en.ts:7713—syncError: (providerName) => \Can't connect to ${providerName}``That reproduces the reported string character for character.
App sends no approval-related parameter when connecting.
ConnectPolicyToGustoParamsis{policyID}only, andgetGustoSetupLinkjust opens that URL in the browser. So the approval-mode write that gets rejected happens entirely on the server during (or right after)ConnectPolicyToGusto.Why it collides: a Gusto HR connection takes over the workspace's approval flow — when its mode is
BASICorMANAGER, App makes the whole Workflows tab read-only (HRUtils.ts:83-97). TheApplause Gusto (DO NOT DELETE)workspace already has approval workflow rules configured, so the backend's attempt to hand approvals to Gusto is blocked by the approval-workflow guard, which returns jsonCode 401 with that message.What changes do you think we should make in order to solve the problem?
The fix is not in this repo.
ConnectPolicyToGustoneeds to stop attempting an approval-mode write that conflicts with the policy's existingapprovalRules— either connect first and let the admin choose the mode afterwards (theCUSTOMoption already exists atCONST/index.ts:3351-3357), or clear/override the conflicting rules as part of connecting. This needs an internal engineer withAuth/Web-Expensifyaccess.Two genuine but secondary App-side problems, worth fixing regardless of the backend outcome:
MergeProviderCard.tsx:87interpolates an arbitrary server string, jsonCode prefix and all. Strip the numeric code or map known codes to real copy.handleConnectvalidates only the setup link, write access, and "another HR provider is connected" — it never looks atpolicy.rules.approvalRules, despitehasConfiguredRulesalready existing. A confirm modal here would mirror the existing "Change approval mode?" prompt atHRApprovalModePageBase.tsx:101-117.What alternative solutions did you explore?
Alternatives considered and why they were ruled out
lastSync.isAuthenticationErroris false — otherwiseMergeProviderCard.tsx:73-84would have rendered theauthenticationErrorcopy with a Reconnect link instead. The message text is also Expensify-internal policy language, not anything Gusto would emit. The401is a jsonCode embedded in the message body, not an auth failure.approvalModeduring connect. Ruled out — the connect params are{policyID}only, andUpdateGustoApprovalMode/UpdateGustoFinalApproverfire only from the dedicated settings pages, which are gated behindstate.isConnected(hr/utils.ts:218-238).lastSync. Worth checking on the backend side, since it changes where the guard needs relaxing.What I could not verify: VictoriaLogs was unavailable in this run, so there is no production confirmation of frequency or blast radius (does this hit every workspace with approval rules, or only this one?). Reproducing in a test session also isn't possible without the Applause tester account and live Gusto credentials.
Data flow, for reference:
MergeConnectionsPageBase.tsx:104/api/ConnectPolicyToGusto?policyID=<id>→ConnectToMergeFlow/index.tsx:12-14lastSync = {isSuccessful: false, errorDate, errorMessage: "401 Approval workflow…"}hr/utils.ts:81-89surfaces it → rendered on the cardRelated issues: I scanned open
Expensify/Appissues for Gusto connect failures and found no duplicate.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/101727)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run
melvin-bot commentedon Sep 21, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @FitseTLT (
External)melvin-bot commentedon Sep 21, 2026
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
melvin-bot commentedon Sep 24, 2026
@FitseTLT Whoops! This issue is 2 days overdue. Let's get this updated quick!
melvin-bot commentedon Sep 28, 2026
@FitseTLT 6 days overdue. This is scarier than being forced to listen to Vogon poetry!
FitseTLT commentedon Sep 29, 2026
Reviewing tomorrow
FitseTLT commentedon Oct 1, 2026
@Gonals trying to reproduce it. Asking here Even if I reproduce it looks highly likely that it is a BE issue to fix.
melvin-bot commentedon Oct 5, 2026
@Gonals @FitseTLT this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
melvin-bot commentedon Oct 6, 2026
@FitseTLT Eep! 4 days overdue now. Issues have feelings too...
Gonals commentedon Oct 7, 2026
Fix deployed to staging
melvin-bot commentedon Oct 12, 2026
@Gonals Huh... This is 4 days overdue. Who can take care of this?
melvin-bot commentedon Oct 14, 2026
@Gonals 6 days overdue. This is scarier than being forced to listen to Vogon poetry!
Gonals commentedon Oct 15, 2026
Should be fixed