Skip to content

Gusto - Unable to connect - Error: "We've locked your account" #94927

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.4.23-0
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/folder/49545954/test-cases/113539413
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: iOS
App Component: User Settings

Action Performed:

Precondition: use account applausetester+gusto@applause.expensifail.com

  1. Navigate to Applause Gusto [DO NOT DELETE] WS
  2. Tap on HR > Tap connect for Gusto
  3. Enter email and password: Use Gusto Demo app credentials from 1Password
  4. Tap Continue

Expected Result:

Able to connect with Gusto. the panel title reads "Successfully synced your Gusto connection!"

Actual Result:

Error: "We've locked your account
To keep your information safe, we've temporarily locked your account.
Check your email (and maybe your spam folder) for instructions on how to sign in.
Send"

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7194851_1782774745286.ScreenRecording_06-29-2026_19-09-43_1.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Rizky Gunawan
Bug ID: 7194851

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @youssef-lr

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 30, 2026
  2. MelvinBot commented on Jun 30, 2026

    @MelvinBot
    Contributor

    Issue Analysis

    Root Cause: This is a backend/internal issue, not an App bug. The "We've locked your account" screen is Expensify's standard account-lockout page — it is served by the backend, not rendered by the App. (The string does not exist anywhere in Expensify/App; the only nearby match is the unrelated cardLocked copy in en.ts.)

    The App's only role in the Gusto HR connection is to build a backend command URL and hand the user off to it: getGustoSetupLink calls READ_COMMANDS.CONNECT_POLICY_TO_GUSTO with shouldSkipWebProxy: true. From that point the Gusto credential entry and OAuth/sync are handled by the backend. The account lockout is being triggered server-side during that flow.

    Recommended Fix: Requires investigation outside the App repo (Web-Expensify / Auth — the CONNECT_POLICY_TO_GUSTO handler and the account-lock mechanism). This should be escalated to an internal engineer with access to those repos. There is no App-side code change that would resolve this. A likely line of investigation: the Gusto setup flow re-validating the Expensify session is tripping the account-lock guard for applausetester+gusto@applause.expensifail.com (the account may currently be locked — note the test instructions reuse Gusto demo credentials, which can cause repeated failed auth attempts).

    Investigation details
    • Symptom: During HR → Connect Gusto, after entering Gusto demo credentials, the user sees "We've locked your account / To keep your information safe, we've temporarily locked your account. Check your email… Send". Reproducible in staging and production; iOS & Android.
    • Evidence the message is backend-served: grep -rin "locked your account|keep your information safe|temporarily locked your" over App/src returns no matches. The "Send" button (resend magic-link/sign-in instructions) is the Expensify account-lockout page, not Gusto's UI.
    • App hand-off point: src/libs/actions/connections/Gusto.ts:12-18 — the App just returns the command URL and navigates there; it does not handle credentials or the lock response.
    • Alternative explanations considered: (1) An App-side error map surfacing this copy — ruled out, the string isn't in the repo. (2) Gusto's own lockout — ruled out by the Expensify-specific "Send instructions to your email" wording. The remaining explanation is the Expensify account-lock guard firing server-side during the connect flow.
    • Confidence: Medium-high that the root cause is backend. Exact trigger needs server logs / Auth code review, which require internal access.

    Next Steps for Contributor+ team:
    This is not actionable in Expensify/App. Please escalate to an internal engineer to investigate the CONNECT_POLICY_TO_GUSTO handler and the account-lock behavior in Web-Expensify/Auth, and to confirm whether the applausetester+gusto account is currently locked.
    To refine: @MelvinBot <your feedback>

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jun 30, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jun 30, 2026
  5. neerajbachani commented on Jun 30, 2026

    @neerajbachani
    Contributor

    proposal

  6. melvin-bot commented on Jun 30, 2026

    @melvin-bot

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

  7. shivang-goliyan commented on Jun 30, 2026

    @shivang-goliyan
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-06-30 03:50:04 UTC.

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When the tester connects Gusto from HR settings on iOS or Android, the connect screen shows "We've locked your account / To keep your information safe, we've temporarily locked your account. Check your email… Send" instead of completing the sync. The account ends up locked rather than connected.

    What is the root cause of that problem?

    That screen is not rendered by the App. It's Expensify's own account-lockout page (the giveaway is the "Check your email… Send" resend-instructions button), served by the backend inside the connect session. Grepping src/ for "locked your account", "keep your information safe", and "temporarily locked" returns nothing, so no App copy or error map produces it.

    The App's only job in this flow is to build a backend command URL and hand the user off to it. getGustoSetupLink (src/libs/actions/connections/Gusto.ts:18) builds commandURL + new URLSearchParams({policyID}).toString(). getCommandURL (src/libs/ApiUtils.ts:61) appends a single clean ? only when one isn't already there, and URLSearchParams produces policyID=123, so the URL is well-formed. On native, getShortLivedAuthTokenURL (src/libs/actions/Link.ts:425-438) fetches a short-lived token and appends it, then the link loads in the WebView (Android) / ASWebAuthenticationSession (iOS). From there the credential entry, OAuth, and sync are all backend (CONNECT_POLICY_TO_GUSTO).

    A couple of details rule out the App as the cause. The same builder and hand-off serve Zenefits and Merge HR, and those connect fine. The connect call fires exactly once, guarded by hasFetched.current in ConnectToHRFlow/index.native.tsx and hasOpened.current in index.ios.tsx, so there's no retry storm hammering the endpoint. What's left is the server-side lock firing for applausetester+gusto@applause.expensifail.com. The test steps reuse shared Gusto demo credentials across regression runs, which is exactly the kind of repeated-auth pattern that trips Expensify's anti-fraud account lock. The account is almost certainly already locked.

    What changes do you think we should make in order to solve the problem?

    There's no App-side code change that fixes this, because the App isn't where the lock is decided. This needs to go to an internal engineer with access to Web-Expensify / Auth: confirm whether applausetester+gusto is currently locked (and unlock it for testing), and review the account-lock guard against the CONNECT_POLICY_TO_GUSTO hand-off. If the goal is also to handle a locked account more gracefully in the connect WebView, that's still a backend decision about what gets rendered in that session.

    What alternative solutions did you explore? (Optional)

    I looked hard at the URL building, since that's the one piece the App controls. One theory is that the native hand-off omits the email param that buildOldDotURL (Link.ts:60-63) attaches, leaving the token unbound. But the hand-off authenticates with the short-lived authToken, which the backend resolves to the account on its own, the URL itself is well-formed, and the identical native path works for the other HR providers. The page being shown is the "your account is locked, resend instructions" page, not a sign-in-failed page, which points to a lock that already exists rather than a bad request. I also checked whether an App error map could surface this copy. It can't, the strings aren't in the repo.

  8. changed the title [-]Gusto - Unable to connect - Error: "We've locked your account"[/-] [+][$250] Gusto - Unable to connect - Error: "We've locked your account"[/+] on Jun 30, 2026
  9. melvin-bot commented on Jun 30, 2026

    @melvin-bot
  10. yusufdeveloper2903 commented on Jun 30, 2026

    @yusufdeveloper2903
    Contributor

    Proposal

    What is the root cause of that problem?

    The Gusto connect flow opens an OldDot authenticated URL. The setup link is built by getGustoSetupLink, which targets the OldDot ConnectPolicyToGusto command with shouldSkipWebProxy: true, i.e. a bare https://www.expensify.com/api/ConnectPolicyToGusto?policyID=… URL with no credentials attached:

    function getGustoSetupLink(policyID: string) {
    const params: ConnectPolicyToGustoParams = {policyID};
    const commandURL = getCommandURL({
    command: READ_COMMANDS.CONNECT_POLICY_TO_GUSTO,
    shouldSkipWebProxy: true,
    });
    return commandURL + new URLSearchParams(params).toString();
    }

    On native that link is authenticated by getShortLivedAuthTokenURL, which fetches a short-lived token via OPEN_OLD_DOT_LINK and appends only authToken to the URL:

    function getShortLivedAuthTokenURL(setupLink: string): Promise<string> {
    // eslint-disable-next-line rulesdir/no-api-side-effects-method
    return API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.OPEN_OLD_DOT_LINK, {}, {})
    .then((response) => {
    if (!response?.shortLivedAuthToken) {
    return setupLink;
    }
    return Url.appendParam(setupLink, 'authToken', response.shortLivedAuthToken);
    })
    .catch((error) => {
    Log.warn('[Link] Failed to fetch short-lived auth token', {error});
    return setupLink;
    });
    }

    That URL is then loaded inside the in-app WebView (Android) and the ephemeral ASWebAuthenticationSession (iOS) — both of which start with no Expensify session cookies, so the URL params are the only identity OldDot receives:

    const fetchAuthUrl = () => {
    if (hasFetched.current) {
    return;
    }
    hasFetched.current = true;
    getShortLivedAuthTokenURL(setupLink).then(setAuthenticatedUrl);
    };

    const openSession = () => {
    if (hasOpened.current) {
    return;
    }
    hasOpened.current = true;
    getShortLivedAuthTokenURL(setupLink)
    // CONST.DEEPLINK_BASE_URL is used as a sentinel so ASWebAuthenticationSession
    // auto-dismisses when the flow redirects back to the app via deep link.
    .then((url) => {
    if (isDismissed.current) {
    return;
    }
    return openAuthSessionAsync(url, CONST.DEEPLINK_BASE_URL, {preferEphemeralSession: true});
    })
    .finally(dismiss);
    };

    The problem is that OldDot authenticates a link with authToken plus the email (the partnerUserID the token is bound to). Every other OldDot deep link in the app is built through buildOldDotURL, which always appends both authToken and email:

    const authTokenParam = shortLivedAuthToken ? `authToken=${shortLivedAuthToken}` : '';
    const emailParam = `email=${encodeURIComponent(currentUserEmail)}`;
    const paramsArray = [authTokenParam, emailParam];
    const params = paramsArray.filter(Boolean).join('&');

    The web path proves this: ConnectToHRFlow (web) routes the same setup link through openLink → openOldDotLink → buildOldDotURL, so on web the OldDot URL carries email and the connection authenticates correctly (web is not in the affected platforms list):

    function ConnectToHRFlow({setupLink}: ConnectToHRFlowProps) {
    const {environmentURL} = useEnvironment();
    useEffect(() => {
    openLink(setupLink, environmentURL);
    }, [environmentURL, setupLink]);
    return null;
    }

    function openOldDotLink(url: string, shouldOpenInSameTab = false) {
    if (getIsOffline()) {
    buildOldDotURL(url).then((oldDotURL) => openExternalLink(oldDotURL, undefined, shouldOpenInSameTab));
    return;
    }
    // If shortLivedAuthToken is not accessible, fallback to opening the link without the token.
    asyncOpenURL(
    // eslint-disable-next-line rulesdir/no-api-side-effects-method
    API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.OPEN_OLD_DOT_LINK, {}, {})
    .then((response) => (response ? buildOldDotURL(url, response.shortLivedAuthToken) : buildOldDotURL(url)))
    .catch(() => buildOldDotURL(url)),
    (oldDotURL) => oldDotURL,
    undefined,
    shouldOpenInSameTab,
    );
    }

    So: native loads the OldDot URL with authToken but no email, so OldDot can't bind the short-lived token to the account and treats each cookie-less WebView load as a failed sign-in; the repeated failed attempts trip OldDot's security lock and the WebView renders the "We've locked your account" page → the symptom. The omission is identical on both native platforms, which is exactly why iOS App and Android App are affected while web/mWeb are not.

    What changes do you think we should make in order to solve the problem?

    Make the native auth URL carry the same credentials as every other OldDot link by appending the email param alongside authToken, reusing the exact pattern already in buildOldDotURL (Link.ts#L60-L63). currentUserEmail is already maintained in scope in this same file via the session Onyx connection (Link.ts#L41-L47), so no new wiring is needed — only Url.appendParam, already used here.

    In getShortLivedAuthTokenURL:

    +    const setupLinkWithEmail = Url.appendParam(setupLink, 'email', currentUserEmail);
         // eslint-disable-next-line rulesdir/no-api-side-effects-method
         return API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.OPEN_OLD_DOT_LINK, {}, {})
             .then((response) => {
                 if (!response?.shortLivedAuthToken) {
    -                return setupLink;
    +                return setupLinkWithEmail;
                 }
    -            return Url.appendParam(setupLink, 'authToken', response.shortLivedAuthToken);
    +            return Url.appendParam(setupLinkWithEmail, 'authToken', response.shortLivedAuthToken);
             })
             .catch((error) => {
                 Log.warn('[Link] Failed to fetch short-lived auth token', {error});
    -            return setupLink;
    +            return setupLinkWithEmail;
             });

    This mirrors buildOldDotURL exactly (both authToken and email, and email is attached even on the token-failure/fallback paths), so the native Gusto/Merge HR WebViews authenticate against OldDot the same way the web flow already does. The fix is a single function with zero new call sites; it automatically covers both native consumers (index.native.tsx and index.ios.tsx) and every HR provider (Gusto, Zenefits, Merge) that shares this flow. Minor changes/improvements can be discussed in the PR phase.

    What alternative solutions did you explore? (Optional)

    Route the native flow through openOldDotLink/buildOldDotURL directly instead of getShortLivedAuthTokenURL. That would also include the email, but buildOldDotURL re-prepends the OldDot domain and reshapes the query string, whereas the native setup link is already a full absolute URL — reusing it would risk a malformed URL and changes more behavior. Appending email in getShortLivedAuthTokenURL is the smaller, lower-risk change that fixes the root cause where it actually occurs.

  11. abbasifaizan70 commented on Jun 30, 2026

    @abbasifaizan70
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    • When connecting a workspace to Gusto (Workspace → HR → Connect Gusto), after entering the Gusto credentials and tapping Continue, instead of completing the connection the user is shown the OldDot account-lock screen: "We've locked your account… Check your email (and maybe your spam folder) for instructions on how to sign in." This is reproducible on iOS App and Android App in both staging and production.

    What is the root cause of that problem?

    The HR connect flow builds a setup link that points to an OldDot API command (ConnectPolicyToGusto) with shouldSkipWebProxy: true, carrying only policyID. This URL is then opened inside an isolated web session (an ephemeral ASWebAuthenticationSession on iOS, an incognito/cookie-cleared WebView on Android), so the web session starts with no Expensify cookies — the URL itself is the only thing that can authenticate the request.

    function getGustoSetupLink(policyID: string) {
    const params: ConnectPolicyToGustoParams = {policyID};
    const commandURL = getCommandURL({
    command: READ_COMMANDS.CONNECT_POLICY_TO_GUSTO,
    shouldSkipWebProxy: true,
    });
    return commandURL + new URLSearchParams(params).toString();
    }

    On iOS the flow fetches a short-lived auth token and opens the resulting URL with preferEphemeralSession: true, meaning the session does not share any cookies with Safari and must rely entirely on the credentials in the URL.

    const openSession = () => {
    if (hasOpened.current) {
    return;
    }
    hasOpened.current = true;
    getShortLivedAuthTokenURL(setupLink)
    // CONST.DEEPLINK_BASE_URL is used as a sentinel so ASWebAuthenticationSession
    // auto-dismisses when the flow redirects back to the app via deep link.
    .then((url) => {
    if (isDismissed.current) {
    return;
    }
    return openAuthSessionAsync(url, CONST.DEEPLINK_BASE_URL, {preferEphemeralSession: true});
    })
    .finally(dismiss);
    };

    The token is added by getShortLivedAuthTokenURL, which appends only authToken to the setup link:

    function getShortLivedAuthTokenURL(setupLink: string): Promise<string> {
    // eslint-disable-next-line rulesdir/no-api-side-effects-method
    return API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.OPEN_OLD_DOT_LINK, {}, {})
    .then((response) => {
    if (!response?.shortLivedAuthToken) {
    return setupLink;
    }
    return Url.appendParam(setupLink, 'authToken', response.shortLivedAuthToken);
    })
    .catch((error) => {
    Log.warn('[Link] Failed to fetch short-lived auth token', {error});
    return setupLink;
    });
    }

    Compare this with the canonical OldDot deep-link builder buildOldDotURL, which always appends both authToken and email (the account the short-lived token belongs to). OldDot validates a short-lived token against the email/partnerUserID supplied alongside it:

    function buildOldDotURL(url: string, shortLivedAuthToken?: string): Promise<string> {
    const hashIndex = url.lastIndexOf('#');
    const hasHashParams = hashIndex !== -1;
    const hasURLParams = url.indexOf('?') !== -1;
    let originURL = url;
    let hashParams = '';
    if (hasHashParams) {
    originURL = url.substring(0, hashIndex);
    hashParams = url.substring(hashIndex);
    }
    const authTokenParam = shortLivedAuthToken ? `authToken=${shortLivedAuthToken}` : '';
    const emailParam = `email=${encodeURIComponent(currentUserEmail)}`;
    const paramsArray = [authTokenParam, emailParam];
    const params = paramsArray.filter(Boolean).join('&');
    return Environment.getOldDotEnvironmentURL().then((environmentURL) => {
    const oldDotDomain = addTrailingForwardSlash(environmentURL);
    // If the URL contains # or ?, we can assume they don't need to have the `?` token to start listing url parameters.
    return `${oldDotDomain}${originURL}${hasURLParams ? '&' : '?'}${params}${hashParams}`;
    });
    }

    Because getShortLivedAuthTokenURL omits the email parameter, OldDot receives a short-lived token with no associated account to validate it against. In a cookie-less web session this authentication cannot succeed, so the request is treated as an unauthenticated/failed sign-in attempt and OldDot serves the temporary account-lock screen instead of the Gusto OAuth page.

    What changes do you think we should make in order to solve the problem?

    Make getShortLivedAuthTokenURL mirror buildOldDotURL by appending the current user's email next to authToken, so OldDot can validate the short-lived token in the cookie-less web session. currentUserEmail is already maintained from the session in this module.

    function getShortLivedAuthTokenURL(setupLink: string): Promise<string> {
    // eslint-disable-next-line rulesdir/no-api-side-effects-method
    return API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.OPEN_OLD_DOT_LINK, {}, {})
    .then((response) => {
    if (!response?.shortLivedAuthToken) {
    return setupLink;
    }
    return Url.appendParam(setupLink, 'authToken', response.shortLivedAuthToken);
    })
    .catch((error) => {
    Log.warn('[Link] Failed to fetch short-lived auth token', {error});
    return setupLink;
    });
    }

    .then((response) => {
        if (!response?.shortLivedAuthToken) {
            return setupLink;
        }
        const linkWithToken = Url.appendParam(setupLink, 'authToken', response.shortLivedAuthToken);
        return Url.appendParam(linkWithToken, 'email', encodeURIComponent(currentUserEmail));
    })

    This applies to all HR providers that route through getShortLivedAuthTokenURL (Gusto, Zenefits, Merge HR), since they all build the same kind of shouldSkipWebProxy command URL and open it in an isolated web session.

  12. 12 remaining items

  13. melvin-bot commented on Jul 6, 2026

    @melvin-bot

    Triggered auto assignment to @youssef-lr, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

  14. melvin-bot commented on Jul 7, 2026

    @melvin-bot

    📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

  15. melvin-bot commented on Jul 9, 2026

    @melvin-bot

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

  16. added
    InternalRequires API changes or must be handled by Expensify staff
    and removed
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 10, 2026
  17. changed the title [-][$250] Gusto - Unable to connect - Error: "We've locked your account"[/-] [+]Gusto - Unable to connect - Error: "We've locked your account"[/+] on Jul 10, 2026
  18. removed
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 10, 2026
  19. grgia commented on Jul 10, 2026

    @grgia
    Contributor

    We need to have QA regenerate credentials

  20. IuliiaHerets commented on Jul 10, 2026

    @IuliiaHerets

    Chrome / v9.4.32-3
    Passed

    bandicam.2026-07-10.15-11-07-858.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2InternalRequires API changes or must be handled by Expensify staff

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions