App icon indicating copy to clipboard operation
App copied to clipboard

[$175] [HR Import] Add "Manage connection" to the three-dot menu on healthy Merge connections

Open twisterdotcom opened this issue 5 days ago • 10 comments


Problem

An admin can re-authenticate a Merge connection only after it breaks (isAuthenticationError: true). There is no way to re-authenticate a healthy connection.

Admins need this when the employee whose credentials authorised the connection leaves. The admin must hand the connection over before that account is revoked. Today they must wait for the sync to break, or disconnect and connect again. Disconnecting deletes the Linked Account and loses the connection's settings.

Backend

Done (Integration-Server#9460): a relink to the same Linked Account keeps the connection's config (groups, filters, approval mode, final approver), clears isAuthenticationError, and does not re-run first-time setup. It covers merge_hris and merge_ats.

To do (internal, in the parent issue): start a sync after a relink. The card already shows the syncing state from lastSync.syncStatus, so the App needs no change for this.

Merge opens its update screen, not a new connection, because ConnectPolicyToMerge passes the policy ID as end_user_origin_id. The existing Reconnect action already calls this command on a connected policy. No new command is needed.

Behavior

  • Add Manage connection to the three-dot menu on a connected Merge provider page (HR and Recruiting), above Disconnect.
  • Show it when isMergeConnectionName(card.connectionName) is true and needsReconnect is false. In the error state the menu already shows Reconnect, which calls the same handler.
  • Do not show it for Gusto or Zenefits. They render through the same component but use our own OAuth flows.
  • On press, show a confirmation modal (not the danger variant):
    • Title: Manage {provider} connection
    • Prompt: You'll sign in to {provider} again. Your settings stay the same.
    • Confirm: Continue
  • On confirm, call the existing handleConnect. It opens ConnectToMergeFlow with the card's setupLink.
  • Disable the item when offline, the same as Sync now.
  • Do not change the Reconnect link or menu item in the error state.

Mockups

image image image

Decisions already made

  • Label. Manage connection, not Relink. Merge's update screen also shows field mapping, so the label stays accurate when field-mapping overrides ship.
  • Sync. A relink starts a sync. Merge Link opens in a new tab and the App cannot tell a finished relink from a cancelled one, so the backend starts it.
  • Billing. A relink to the same end_user_origin_id does not create a second Linked Account. No extra cost.
  • Provider picker. getMergeSetupLink() passes the integration slug, so Merge Link goes straight to the admin's own provider login.

Files

  • src/pages/workspace/merge/useMergeProviderCardDetails.tsx: add the item to overflowMenu between getPrimaryMenuItem() and Disconnect. Use useConfirmModal, the same as Disconnect.
  • src/CONST: add MERGE_MENU_MANAGE_CONNECTION to SENTRY_LABEL.WORKSPACE.CONNECTIONS, next to MERGE_MENU_RECONNECT.
  • src/languages/en.ts and the other locale files: menu label, modal title, prompt and confirm text, with the provider name as a parameter.
  • No change: src/pages/workspace/connections/ConnectionsMergePageBase.tsx. handleReconnect works for a healthy connection as-is.

Test steps

  1. On a Control workspace, connect BambooHR or Workday through Merge. Pick groups, set approval mode to Manager and choose a final approver.
  2. Open Workspace > Connections > HR. Confirm the three-dot menu shows Sync now, Manage connection and Disconnect.
  3. Tap Manage connection. Confirm the modal shows, then tap Continue.
  4. Confirm Merge Link opens on the update screen for that provider, with no provider picker.
  5. Sign in again with the same provider account. Confirm the groups, approval mode and final approver are unchanged, with no Complete Setup prompt.
  6. Confirm the Merge dashboard shows one Linked Account for the workspace.
  7. Break the connection (change the provider password). When the Reconnect error shows, confirm the menu shows Reconnect and not Manage connection.
  8. Repeat steps 2–5 on a Recruiting (ATS) connection.
  9. On a Gusto connection, confirm Manage connection does not show.
  10. Go offline. Confirm Manage connection is disabled.

Related issues

  • Expensify/Expensify#678822: parent spec (internal)
  • Expensify/Integration-Server#9460: backend relink handling
  • #90605: error-state Reconnect prompt, same handleConnect entry point
  • #99511: made the Merge card shared with ATS
Upwork Automation - Do Not Edit

twisterdotcom avatar Nov 26 '26 18:11 twisterdotcom

Triggered auto assignment to Design team member for new feature review - @shawnborton (NewFeature)

Investigation Progress:

  • [x] Step 1: Extract symptoms and identifiers from issue
  • [x] Step 2: Form hypothesis
  • [x] Step 3: Pre-fetch hints and scan related issues
  • [x] Step 4: Gather evidence with two researchers
  • [x] Step 5: Evaluate evidence
  • [x] Step 6: Challenge alternatives
  • [x] Step 7: Assess runtime evidence requirements
  • [x] Step 8: Prepare structured analysis

Both investigations support a missing menu entry rather than a restriction in the existing connection handler. App-side changes can stay small; preserving the Linked Account and starting the subsequent sync remain backend-dependent acceptance checks, not verified outcomes.

Proposal

What is the root cause of that problem?

Healthy Merge connections have no reauthentication entry point. The shared card only calls handleConnect from Reconnect when needsReconnect is true; otherwise it offers Complete setup or Sync now, followed by Disconnect.

The existing page handler already accepts healthy connections, so no new command or connection-flow change is needed.

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

  • Insert Manage connection immediately above Disconnect when isMergeConnectionName(card.connectionName) && !card.needsReconnect.
  • Disable it offline and close the overflow menu before opening the confirmation.
  • Use a non-danger confirmation with the specified provider-specific title and prompt. Reuse Continue and Cancel translations.
  • Only on confirmation, call the existing handleConnect. Never disconnect or replace the connection.
  • Add the menu’s Sentry label and localized strings. Leave error-state Reconnect, Gusto and Zenefits unchanged.
Code evidence and acceptance checks

Test both HR and ATS: menu ordering, confirm versus cancel, offline disabling, authentication errors, incomplete setup, and Gusto/Zenefits exclusion. Use !needsReconnect, not a generic “no errors” condition.

Confidence: Medium. Static code supports the App change; browser and backend behavior were not verified. Settings retention, one Linked Account, provider-picker suppression and post-relink sync require end-to-end verification. The pending backend sync work remains a separate internal dependency.

What alternative solutions did you explore? (Optional)

Broadening Reconnect would change the established error-state behavior. Disconnecting first would violate the requirement to preserve the existing connection. Neither is necessary.

Related: Hide the Time Sensitive “Fix connection” card while that connection is syncing concerns adjacent sync-state behavior, not the same missing action.


Next Steps for Contributor+ team: To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/108123) to create a draft PR. To refine: @MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.


view run

MelvinBot avatar Nov 26 '26 18:11 MelvinBot

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

Job added to Upwork: https://www.upwork.com/jobs/~022126015789739664092

Proposal

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

On a healthy Merge HR or Recruiting connection, the three-dot menu has no way to re-authenticate. An admin can only relink after the connection breaks, or by disconnecting, which deletes the Linked Account and its settings.

What is the root cause of that problem?

In src/pages/workspace/merge/useMergeProviderCardDetails.tsx, overflowMenu is built from getPrimaryMenuItem() plus Disconnect. getPrimaryMenuItem() only returns the handleConnect item (Reconnect) when card.needsReconnect is true; otherwise it returns Complete setup or Sync now. So handleConnect is never reachable for a healthy connection, even though handleReconnect in ConnectionsMergePageBase.tsx only checks card.setupLink and write access, not the error state.

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

  1. In useMergeProviderCardDetails.tsx, build the menu as [getPrimaryMenuItem(), ...manageConnectionItem, disconnectItem], where the Manage connection item is added only when isMergeConnectionName(card.connectionName) && !card.needsReconnect (import isMergeConnectionName from @libs/merge/MergeUtils next to showMergeManualSyncLimitModalIfReached). This keeps Gusto/Zenefits and the error-state Reconnect unchanged.
  2. The item uses icons.Sync, disabled: isOffline, shouldCallAfterModalHide: true, and on select calls showConfirmModal (same pattern as Disconnect, but without buttonVariant: CONST.BUTTON_VARIANT.DANGER) with the new title/prompt, confirmText: translate('common.continue') and cancelText: translate('common.cancel'). On result?.action === ModalActions.CONFIRM, call the existing handleConnect.
  3. Add MERGE_MENU_MANAGE_CONNECTION to src/CONST/SENTRY_LABEL.ts next to MERGE_MENU_RECONNECT.
  4. Add workspace.merge.manageConnection, manageConnectionTitle(providerName) and manageConnectionPrompt(providerName) to src/languages/en.ts (beside disconnectTitle / disconnectPrompt) and the other locale files.

No change to ConnectionsMergePageBase.tsx or the Merge actions, as the issue says.

What specific scenarios should we cover in automated tests?

A hook/component test for the Merge provider card: a connected healthy Merge HR and ATS card shows Sync now, Manage connection, Disconnect in that order; a needsReconnect card shows Reconnect and not Manage connection; a Gusto/Zenefits card doesn't show it; the item is disabled offline; confirming calls handleConnect once and cancelling doesn't call it.

What alternative solutions did you explore? (Optional)

Reusing the Reconnect label for healthy connections, but the issue already decided on Manage connection, and keeping it a separate item keeps the error-state menu unchanged.

fitzyracing1 avatar Nov 26 '26 19:11 fitzyracing1

Proposal

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

Admins cannot re-authenticate a healthy Merge HR or Recruiting connection from its three-dot menu. Today they have to wait for the connection to break (needsReconnect) or disconnect and reconnect, which deletes the Linked Account and its configuration.

What is the root cause of that problem?

In src/pages/workspace/merge/useMergeProviderCardDetails.tsx, overflowMenu only contains [getPrimaryMenuItem(), disconnectItem]. getPrimaryMenuItem() only wires handleConnect when card.needsReconnect is true (Reconnect), so healthy Merge connections have no menu entry to open ConnectToMergeFlow even though handleReconnect in ConnectionsMergePageBase.tsx already works for any connected card with a setupLink.

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

  1. src/pages/workspace/merge/useMergeProviderCardDetails.tsx:
    • Add 'Key' to useMemoizedLazyExpensifyIcons(['Sync', 'Trashcan', 'Building', 'CheckCircle', 'Key']) to match the key icon shown in the mockup (@assets/images/key.svg in expensify-icons.chunk.ts).
    • Import isMergeConnectionName from @libs/merge/MergeUtils alongside showMergeManualSyncLimitModalIfReached.
    • Insert a Manage connection item in overflowMenu between getPrimaryMenuItem() and Disconnect when isMergeConnectionName(card.connectionName) && !card.needsReconnect:
      • icon: icons.Key
      • text: translate('workspace.merge.manageConnection')
      • sentryLabel: CONST.SENTRY_LABEL.WORKSPACE.CONNECTIONS.MERGE_MENU_MANAGE_CONNECTION
      • disabled: isOffline
      • shouldCallAfterModalHide: true
      • onSelected: check if (!canWriteMoreFeatures) { showReadOnlyModal(); return; } first (consistent with completeSetupRoute and staleGroupsRoute in the same hook, so read-only admins aren't shown the confirm modal before being blocked in handleReconnect), then call showConfirmModal without CONST.BUTTON_VARIANT.DANGER using title: translate('workspace.merge.manageConnectionTitle', card.displayName), prompt: translate('workspace.merge.manageConnectionPrompt', card.displayName), confirmText: translate('common.continue'), and cancelText: translate('common.cancel'). On result?.action === ModalActions.CONFIRM, call handleConnect().
  2. src/CONST/SENTRY_LABEL.ts:
    • Add MERGE_MENU_MANAGE_CONNECTION: 'WorkspaceConnections-MergeMenuManageConnection' under WORKSPACE.CONNECTIONS, next to MERGE_MENU_RECONNECT.
  3. src/languages/en.ts (and the remaining 10 locale files):
    • Add manageConnection: 'Manage connection', manageConnectionTitle: (providerName: string) => \Manage ${providerName} connection`, and manageConnectionPrompt: (providerName: string) => `You'll sign in to ${providerName} again. Your settings stay the same.`underworkspace.merge`.
  4. Leave src/pages/workspace/connections/ConnectionsMergePageBase.tsx unchanged as specified.

What specific scenarios should we cover in automated tests?

  • Unit test useMergeProviderCardDetails:
    • Healthy Merge HR and ATS cards render [Sync now / Complete setup, Manage connection, Disconnect] in order with icons.Key.
    • Cards with needsReconnect: true render [Reconnect, Disconnect] without Manage connection.
    • Non-Merge cards (Gusto / Zenefits) do not render Manage connection.
    • Manage connection is disabled when isOffline is true.
    • Selecting Manage connection when canWriteMoreFeatures is false triggers showReadOnlyModal() without opening the confirm modal.
    • Confirming the modal calls handleConnect(); cancelling does not.

What alternative solutions did you explore? (Optional)

Letting handleConnect() handle the canWriteMoreFeatures check after modal confirmation, but gating before showConfirmModal avoids a redundant confirmation prompt for read-only admins and matches the existing guards in useMergeProviderCardDetails.

oktayudha05 avatar Nov 26 '26 21:11 oktayudha05

📣 @oktayudha05! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

melvin-bot[bot] avatar Nov 26 '26 21:11 melvin-bot[bot]

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01eb24d273a13ebc7e

oktayudha05 avatar Nov 26 '26 22:11 oktayudha05

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 26 '26 22:11 melvin-bot[bot]

Proposal

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

On a connected, healthy Merge HR or Recruiting provider page, the three-dot menu has no option to re-authenticate the connection. Admins currently have to wait for an authentication error (needsReconnect) or disconnect and reconnect, which deletes the Linked Account and wipes saved workspace configuration.

What is the root cause of that problem?

In src/pages/workspace/merge/useMergeProviderCardDetails.tsx, overflowMenu only includes [getPrimaryMenuItem(), disconnectItem]. getPrimaryMenuItem() only wires handleConnect when card.needsReconnect is true (Reconnect); for healthy connections it returns Complete setup or Sync now, leaving no entry point to handleConnect even though handleReconnect in ConnectionsMergePageBase.tsx already works for healthy connected cards.

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

  1. src/pages/workspace/merge/useMergeProviderCardDetails.tsx
    • Load the 'Key' icon in useMemoizedLazyExpensifyIcons (matching the key icon in the mockup) and import isMergeConnectionName from @libs/merge/MergeUtils.
    • Insert a Manage connection item in overflowMenu between getPrimaryMenuItem() and Disconnect only when isMergeConnectionName(card.connectionName) && !card.needsReconnect. This excludes Gusto/Zenefits and leaves the error-state Reconnect item untouched.
    • Configure the item with:
      • icon: icons.Key
      • text: translate('workspace.merge.manageConnection')
      • sentryLabel: CONST.SENTRY_LABEL.WORKSPACE.CONNECTIONS.MERGE_MENU_MANAGE_CONNECTION
      • disabled: isOffline
      • shouldCallAfterModalHide: true (ensures the three-dot popover finishes closing before presenting the confirmation modal)
    • In onSelected:
      • Guard !canWriteMoreFeatures first and call showReadOnlyModal() so read-only callers do not see a confirmation dialog before being blocked in handleReconnect.
      • Open showConfirmModal using the default non-danger (SUCCESS) confirm button variant with:
        • title: translate('workspace.merge.manageConnectionTitle', card.displayName)
        • prompt: translate('workspace.merge.manageConnectionPrompt', card.displayName)
        • confirmText: translate('common.continue')
        • cancelText: translate('common.cancel')
        • shouldDisableConfirmButtonWhenOffline: true (prevents confirming if the user goes offline while the modal is already open)
      • When result?.action === ModalActions.CONFIRM, call handleConnect(). Because ConfirmModalWrapper resolves the promise inside onModalHide, launching ConnectToMergeFlow's fullscreen modal on iOS/Android will not collide with the closing confirmation modal.
  2. src/CONST/SENTRY_LABEL.ts
    • Add MERGE_MENU_MANAGE_CONNECTION: 'WorkspaceConnections-MergeMenuManageConnection' under WORKSPACE.CONNECTIONS, next to MERGE_MENU_RECONNECT.
  3. Localization (src/languages/en.ts and the remaining 10 locale files)
    • Add manageConnection, manageConnectionTitle(providerName), and manageConnectionPrompt(providerName) under workspace.merge, matching the exact copy in the spec and reusing common.continue / common.cancel.
  4. No changes to src/pages/workspace/connections/ConnectionsMergePageBase.tsx
    • handleReconnect already handles healthy Merge connections and passes card.setupLink into ConnectToMergeFlow.

What specific scenarios should we cover in automated tests?

Add unit tests for useMergeProviderCardDetails covering:

  • Healthy Merge HR and Recruiting cards show [Sync now (or Complete setup), Manage connection, Disconnect] in order with icons.Key.
  • Merge cards with needsReconnect: true show Reconnect and omit Manage connection.
  • Direct HR providers (Gusto, Zenefits) omit Manage connection.
  • Manage connection is disabled when offline, and its confirm modal disables Continue when offline.
  • Read-only state (!canWriteMoreFeatures) triggers showReadOnlyModal without opening the confirmation modal.
  • Confirming calls handleConnect once; cancelling does not call handleConnect.

What alternative solutions did you explore? (Optional)

  • Relying solely on ConnectionsMergeProviderCard hiding the three-dot menu when !canWriteMoreFeatures (or letting handleReconnect check write access after confirmation) would leave the hook itself inconsistent with completeSetupRoute/staleGroupsRoute and could show a pointless confirm dialog to read-only callers.
  • Omitting shouldDisableConfirmButtonWhenOffline on the confirm modal would let a user who loses connectivity while the dialog is open still trigger ConnectToMergeFlow offline.

ductai05 avatar Nov 27 '26 01:11 ductai05