Skip to content

[Payment due @mkhutornyi] Keep approval workflow rules working with HR integrations - #102750

Merged
marcaaron merged 11 commits into
mainfrom
alberto-gustoFix
Oct 6, 2026
Merged

marcaaron merged 11 commits into
mainfrom
alberto-gustoFix

Conversation

@Gonals

@Gonals Gonals commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

HELD on https://github.com/Expensify/Auth/pull/24990

Explanation of Change

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/687046
PROPOSAL:

Tests

  1. Log into Newdot and go to Workspace->workflows->approvals. Disable and enable to have a fresh one.
  2. Add a second approver to the default workflow and a new workflow
  3. In Workspace -> HR (you may need to enable it), connect to Gusto. 1password has what you need.
  4. Confirm it starts with a Custom approval setting as default
  5. Confirm the Gusto imported users are added to the default workflow by either checking the rules in the DB or in Onyx in Newdot:
Screenshot 2026-09-30 at 17 14 39 6. Change the Gusto configuration to the "Basic" approval setting. 7. Confirm all approval rules have been removed.
  • Verify that no errors appear in the JS console

Offline tests

None

QA Steps

Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

The backend deletes a workspace's approval workflow rules when an HR or recruiting connection switches to a
mode where it sets the approvers, so the approval mode pages say so and use a danger confirm button.
@Gonals Gonals self-assigned this Oct 1, 2026
@Gonals Gonals changed the title Keep approval workflow rules working with HR integrations [HOLD] Keep approval workflow rules working with HR integrations Oct 1, 2026
@OSBotify

This comment has been minimized.

@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/libs/WorkflowUtils.ts 93.56% <100.00%> (+0.01%) ⬆️
src/libs/actions/Workflow.ts 87.09% <100.00%> (+0.26%) ⬆️
src/libs/actions/connections/Gusto.ts 62.50% <100.00%> (+42.50%) ⬆️
src/libs/actions/connections/Zenefits.ts 62.50% <100.00%> (+42.50%) ⬆️
src/libs/actions/connections/merge/index.ts 57.44% <100.00%> (+3.95%) ⬆️
src/pages/workspace/hr/utils.ts 96.51% <100.00%> (+0.35%) ⬆️
...pages/workspace/hr/gusto/GustoApprovalModePage.tsx 0.00% <0.00%> (ø)
...ges/workspace/hr/merge/MergeHRApprovalModePage.tsx 0.00% <0.00%> (ø)
...workspace/hr/zenefits/ZenefitsApprovalModePage.tsx 0.00% <0.00%> (ø)
src/pages/workspace/hr/HRApprovalModePageBase.tsx 0.00% <0.00%> (ø)
... and 1 more
... and 8 files with indirect coverage changes

@Gonals
Gonals marked this pull request as ready for review October 1, 2026 14:22
@Gonals
Gonals requested review from a team as code owners October 1, 2026 14:22
@melvin-bot
melvin-bot Bot requested review from mkhutornyi and trjExpensify and removed request for a team October 1, 2026 14:22
@melvin-bot

melvin-bot Bot commented Oct 1, 2026

Copy link
Copy Markdown

@mkhutornyi Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot removed the request for review from a team October 1, 2026 14:22

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 40ccb712b6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread tests/unit/HrUtilsTest.ts Resolved
@trjExpensify

Copy link
Copy Markdown
Contributor

https://github.com/Expensify/Auth/pull/24990#issuecomment-5934484258 is on prod, I think this can come off hold @Gonals.

trjExpensify
trjExpensify previously approved these changes Oct 1, 2026

@trjExpensify trjExpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this, glad we caught it! 👍

@mkhutornyi

mkhutornyi commented Oct 4, 2026 •

Copy link
Copy Markdown

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-10-04.at.7.05.33.PM.mov

@mkhutornyi

Copy link
Copy Markdown

QA Steps

Prerequisites: a Control workspace with Approvals enabled, and the Gusto and Merge ATS test accounts (1Password).

  1. Go to Workspace > Workflows > Approvals and add a second approver to the default workflow.
  2. Go to Workspace > HR and connect Gusto. It starts in Custom approval mode.
  3. Verify the Gusto card shows no Final approver row. (new)
  4. Open Approval mode, select Basic, then tap Save.
  5. Verify the modal says "Changing the approval mode will erase all existing approval workflows…" and the confirm button is red. (new)
  6. Tap Change approval mode.
  7. Go to Workspace > Workflows and verify the approval workflow you edited in step 1 was removed. (new)
    <--- Merge ATS -->
  8. Recreate the approval workflow from step 1.
  9. Go to Workspace > Recruiting, connect Merge ATS, set the approval mode to Basic with a final approver, and tap Save.
  10. Open Approval mode, select Advanced, then tap Save.
  11. Verify the same red "erase all existing approval workflows" modal appears. (new)
  12. Tap Change approval mode, open Approval mode again, keep Advanced, change only the approver field, and tap Save.
  13. Verify it saves without a modal.

@mkhutornyi

This comment has been minimized.

@Gonals Gonals changed the title [HOLD] Keep approval workflow rules working with HR integrations Keep approval workflow rules working with HR integrations Oct 5, 2026
@MelvinBot

Copy link
Copy Markdown
Contributor

Re-review at 67fda61

The latest commit fixes the modal, but one bug from mkhutornyi's last comment is still open: the Merge ATS action deletes approval workflows when the mode doesn't change.

1. A same-mode Merge ATS save still deletes every workflow, with no warning (blocking)

merge/index.ts:139 only checks approvalMode !== CUSTOM. The Merge ATS page still calls the action when you change only the approver field or final approver (MergeATSApprovalModePage.tsx:98-108). Since 67fda61, that save skips the modal (:117-123), so every rule gets an optimistic DELETE and the success data sets it to null.

Fix: build the delete data only when the mode changes, so the action matches the modal:

const shouldDeleteApprovalWorkflowRules = approvalMode !== CONST.MERGE.APPROVAL_MODE.CUSTOM && approvalMode !== currentApprovalMode;

Add the same guard to Gusto.ts:37 and Zenefits.ts:37. Their pages block same-mode saves today (HRApprovalModePageBase.tsx:74), so this only guards against future callers. Add a MergeActionTest case for "same non-custom mode, approver change only → no rule updates".

I haven't checked whether the backend also deletes rules on a same-mode save. If it does, the App side is correct and the modal should come back for that case instead.

2. New test is missing Given/When/Then comments (minor)

HrUtilsTest.ts:682 has no // Given / // When / // Then comments. The repo test guidelines require them. Codex flagged this earlier, and it's still open.

Looks good

  • buildApprovalWorkflowRulesOnyxData reuses the same optimistic, success, and failure handling as setApprovalWorkflowRules.
  • hasApprovalWorkflowRules skips rules that are pending deletion and rules from other workspaces, and tests cover both.
  • Hiding the final approver row in Custom mode is correct, and tests cover it.
CI

test (job 6) fails in tests/unit/SelectFeaturesEmptyTagGroupTest.tsx. This PR doesn't touch that test or the pages it renders, so the failure is unrelated. Check independent approval is expected to fail until the PR gets an independent approval.

@Gonals
Gonals requested a review from mkhutornyi October 6, 2026 08:49
@melvin-bot
melvin-bot Bot requested a review from marcaaron October 6, 2026 08:53
@melvin-bot

melvin-bot Bot commented Oct 6, 2026

Copy link
Copy Markdown

@marcaaron Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot Bot changed the title Keep approval workflow rules working with HR integrations [Payment due @mkhutornyi] Keep approval workflow rules working with HR integrations Oct 6, 2026
@melvin-bot

melvin-bot Bot commented Oct 6, 2026

Copy link
Copy Markdown

🎯 @mkhutornyi, thanks for reviewing and testing this PR! 🎉

A payment issue will be created for your review once this PR is deployed to production.
E/E issue linked to the PR - https://www.github.com/Expensify/Expensify/issues/687046.

If payment is not needed (e.g., regression PR review fix etc), react with 👎 to this comment to prevent the payment issue from being created.

@marcaaron
marcaaron merged commit d708b9e into main Oct 6, 2026
43 of 44 checks passed
@marcaaron
marcaaron deleted the alberto-gustoFix branch October 6, 2026 17:32
@OSBotify

OSBotify commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🚧 marcaaron has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify OSBotify mentioned this pull request Oct 6, 2026
100 tasks done
@OSBotify

OSBotify commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/marcaaron in version: 9.5.4-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed: the article steps still match the app. This PR keeps approval workflow rules in sync with the HR approval mode, hides Final approver in Custom Approval (where it never applied), and adds an in-app warning before workflows are erased.


view run

@jponikarchuk

Copy link
Copy Markdown

This PR failing because of the issue #103307
This issue is reproducible in: All platforms

@OSBotify

OSBotify commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 9.5.4-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@melvin-bot

melvin-bot Bot commented Oct 7, 2026

Copy link
Copy Markdown

🤖 Payment issue created: #103383

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants