-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[NoQA] [HR Import] Rename and parameterize the sync results modal #91285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
grgia
merged 6 commits into
Expensify:main
from
software-mansion-labs:merge-hr/sync-results-modal
May 21, 2026
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
13b81ae
[HR Import] Rename and parameterize the sync results modal
mhawryluk be8e00d
Fix modal close animation
mhawryluk ce001bb
Implement review suggestions
mhawryluk 27c8d45
Implement AI reviewer's suggestion
mhawryluk 8973c5e
Remove unnecessary comment
mhawryluk 0eecf30
Move providerDisplayName to HRSyncResultsModal
mhawryluk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import {useEffect} from 'react'; | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
| import type {TupleToUnion} from 'type-fest'; | ||
| import HRSyncResultsModal from '@components/HRSyncResultsModal'; | ||
| import {useModal} from '@components/Modal/Global/ModalContext'; | ||
| import {getConnectedHRProvider} from '@libs/PolicyUtils'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type {PolicyConnectionSyncProgress} from '@src/types/onyx/Policy'; | ||
| import useOnyx from './useOnyx'; | ||
| import usePrevious from './usePrevious'; | ||
|
|
||
| /** | ||
| * Watches an HR provider's sync progress and automatically opens the `HRSyncResultsModal` | ||
| * when the sync transitions to the `JOB_DONE` stage with a result payload. | ||
| */ | ||
| function useHRSyncResultsModal(policyID: string, connectionSyncProgress: OnyxEntry<PolicyConnectionSyncProgress>, isFocused: boolean) { | ||
|
mhawryluk marked this conversation as resolved.
|
||
| const modal = useModal(); | ||
| const previousSyncProgress = usePrevious(connectionSyncProgress); | ||
|
|
||
| const connectionName = connectionSyncProgress?.connectionName; | ||
| const [providerDisplayName] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, { | ||
|
mhawryluk marked this conversation as resolved.
Outdated
|
||
| selector: (policy) => { | ||
| const hrProvider = getConnectedHRProvider(policy); | ||
| return hrProvider?.displayName ?? CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName as keyof typeof CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY] ?? connectionName ?? ''; | ||
| }, | ||
| }); | ||
|
|
||
| useEffect(() => { | ||
| const syncResult = connectionSyncProgress?.result; | ||
| const isHRSyncDoneWithResult = | ||
| CONST.POLICY.CONNECTIONS.HR_CONNECTION_NAMES.includes(connectionName as TupleToUnion<typeof CONST.POLICY.CONNECTIONS.HR_CONNECTION_NAMES>) && | ||
| connectionSyncProgress?.stageInProgress === CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.JOB_DONE && | ||
| !!syncResult; | ||
| const didTransitionToJobDone = previousSyncProgress?.connectionName === connectionName && previousSyncProgress?.stageInProgress !== CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.JOB_DONE; | ||
| const didHRSyncComplete = isFocused && isHRSyncDoneWithResult && didTransitionToJobDone; | ||
|
|
||
| if (!didHRSyncComplete || !syncResult || !connectionName) { | ||
| return; | ||
| } | ||
|
|
||
| modal.showModal({ | ||
| component: HRSyncResultsModal, | ||
| props: {result: syncResult, providerDisplayName: providerDisplayName ?? ''}, | ||
| id: `${connectionName}-sync-results-${policyID}`, | ||
| }); | ||
| }, [ | ||
| connectionName, | ||
| connectionSyncProgress?.result, | ||
| connectionSyncProgress?.stageInProgress, | ||
| connectionSyncProgress?.timestamp, | ||
| isFocused, | ||
| providerDisplayName, | ||
| policyID, | ||
| previousSyncProgress?.connectionName, | ||
| previousSyncProgress?.stageInProgress, | ||
| modal, | ||
| ]); | ||
| } | ||
|
|
||
| export default useHRSyncResultsModal; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.