Skip to content

Gusto - Can't connect to Gusto an error appear #101727

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: v9.4.90-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/74701746/folder/49545954/113539413/1775332030?status_id=1014144&issue_type=jira&sort=%2Bidentifier
Email or phone of affected tester (no customers): applausetester+gusto@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Windows 10/Chrome
App Component: Workspace Settings

Action Performed:

  1. Open the New Dot app with the account applausetester+gusto@applause.expensifail.com
  2. Navigate to the HR page of the Applause Gusto (DO NOT DELETE) Workspace
  3. Click Connect Gusto - enter credentials - connect, and return to New Dot

Expected Result:

Gusto connect normally

Actual Result:

Error appears: Can't connect to Gusto ("401 Approval workflow rules manage this policy's approval flow")

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome Safari

Screenshots/Videos

Bug7264650_1789911092382.gusto.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7264650

Activity

  1. applause-bot commented on Sep 21, 2026

    @applause-bot
    Author

    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

  2. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 21, 2026
  3. MelvinBot commented on Sep 21, 2026

    @MelvinBot
    Contributor

    Proposal

    ⚠️ 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:

    1. 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.
    2. 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.

    Data flow, for reference:

    1. Connect pressed → MergeConnectionsPageBase.tsx:104
    2. Browser opens /api/ConnectPolicyToGusto?policyID=<id> → ConnectToMergeFlow/index.tsx:12-14
    3. Backend OAuth succeeds, approval-mode write is rejected → 401
    4. Backend writes lastSync = {isSuccessful: false, errorDate, errorMessage: "401 Approval workflow…"}
    5. hr/utils.ts:81-89 surfaces it → rendered on the card

    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.


    view run

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 21, 2026
  5. melvin-bot commented on Sep 21, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @FitseTLT (External)

  6. melvin-bot commented on Sep 21, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  7. melvin-bot commented on Sep 24, 2026

    @melvin-bot

    @FitseTLT Whoops! This issue is 2 days overdue. Let's get this updated quick!

  8. melvin-bot commented on Sep 28, 2026

    @melvin-bot

    @FitseTLT 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

  9. self-assigned this
    on Sep 29, 2026
  10. FitseTLT commented on Sep 29, 2026

    @FitseTLT
    Contributor

    Reviewing tomorrow

  11. FitseTLT commented on Oct 1, 2026

    @FitseTLT
    Contributor

    @Gonals trying to reproduce it. Asking here Even if I reproduce it looks highly likely that it is a BE issue to fix.

  12. melvin-bot commented on Oct 5, 2026

    @melvin-bot

    @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!

  13. melvin-bot commented on Oct 6, 2026

    @melvin-bot

    @FitseTLT Eep! 4 days overdue now. Issues have feelings too...

  14. Gonals commented on Oct 7, 2026

    @Gonals
    Contributor

    Fix deployed to staging

  15. removed their assignment
    on Oct 7, 2026
  16. melvin-bot commented on Oct 12, 2026

    @melvin-bot

    @Gonals Huh... This is 4 days overdue. Who can take care of this?

  17. melvin-bot commented on Oct 14, 2026

    @melvin-bot

    @Gonals 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

  18. Gonals commented on Oct 15, 2026

    @Gonals
    Contributor

    Should be fixed

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

Metadata

Metadata

Assignees

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions