fix: refactor modals part 2 (DisablePage, EnabledPage, LockAccountPage, InitialSettingsPage) - #79550
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@ZhenjaHorbach 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] |
| if (session?.accountID === -1) { | ||
| return; | ||
| } | ||
| setIsLoading(true); |
There was a problem hiding this comment.
❌ CONSISTENCY-5 (docs)
The lockAccount() call lacks error handling. If the API call throws an error, setIsLoading(false) will never be called, leaving the UI stuck in a loading state and providing no feedback to the user.
Suggested fix:
try {
setIsLoading(true);
const response = await lockAccount();
setIsLoading(false);
if (!response?.jsonCode) {
return;
}
if (response.jsonCode === CONST.JSON_CODE.SUCCESS) {
Navigation.navigate(ROUTES.SETTINGS_UNLOCK_ACCOUNT);
} else {
Navigation.navigate(ROUTES.SETTINGS_FAILED_TO_LOCK_ACCOUNT);
}
} catch (error) {
setIsLoading(false);
Log.error("Failed to lock account", error);
// Show error to user
}| }); | ||
| }, [showConfirmModal, translate]); | ||
|
|
||
| useEffect(() => { |
There was a problem hiding this comment.
❌ PERFORMANCE-12 (docs)
The async IIFE in this useEffect initiates an asynchronous operation without cleanup. If the component unmounts while showTwoFactorAuthRequireModal() is waiting for user interaction, the subsequent closeModal() call will execute on an unmounted component, potentially causing issues.
Suggested fix:
useEffect(() => {
if (isEmpty(account?.errorFields?.requiresTwoFactorAuth ?? {})) {
return;
}
let cancelled = false;
(async () => {
await showTwoFactorAuthRequireModal();
if (!cancelled) {
closeModal();
}
})();
return () => {
cancelled = true;
};
}, [account?.errorFields?.requiresTwoFactorAuth, showTwoFactorAuthRequireModal, closeModal]);| const styles = useThemeStyles(); | ||
|
|
||
| const [isVisible, setIsVisible] = useState(false); | ||
| const {asset: ShieldYellow} = useMemoizedLazyAsset(() => loadIllustration('ShieldYellow' as IllustrationName)); |
There was a problem hiding this comment.
❌ CONSISTENCY-3 (docs)
This showTwoFactorAuthRequireModal function is duplicated identically in both EnabledPage.tsx and DisablePage.tsx. The same modal configuration should be extracted to avoid duplication.
Suggested fix:
Create a shared hook or utility:
// In a shared file, e.g., TwoFactorAuth/utils.ts
export function useTwoFactorAuthRequireModal() {
const {translate} = useLocalize();
const {showConfirmModal} = useConfirmModal();
return useCallback(() => {
return showConfirmModal({
title: translate('twoFactorAuth.twoFactorAuthCannotDisable'),
prompt: translate('twoFactorAuth.twoFactorAuthRequired'),
confirmText: translate('common.buttonConfirm'),
shouldShowCancelButton: false,
});
}, [showConfirmModal, translate]);
}Then use it in both files:
const showTwoFactorAuthRequireModal = useTwoFactorAuthRequireModal();There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54ea07b2df
ℹ️ 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".
| confirmText: translate('lockAccountPage.lockAccount'), | ||
| cancelText: translate('common.cancel'), | ||
| shouldShowCancelButton: true, | ||
| danger: true, | ||
| shouldDisableConfirmButtonWhenOffline: true, |
There was a problem hiding this comment.
Block Enter confirmation when offline
Switching this modal to useConfirmModal makes it use ConfirmModalWrapper, which binds the Enter key directly to confirm without checking the disabled state. If the user opens the modal while online and then loses connectivity, the confirm button becomes disabled via shouldDisableConfirmButtonWhenOffline, but pressing Enter will still resolve with CONFIRM and run lockAccount(). The old inline ConfirmModal relied on the button’s Enter handler, which respects the disabled state, so this is a new way to bypass the offline guard.
Useful? React with 👍 / 👎.
|
@truph01 |
|
@ZhenjaHorbach FYI, I addressed all your comments last week. Also, I fixed React compiler issue in this PR |
Reviewer Checklist
Screenshots/VideosAndroid: HybridApp2026-01-27.14.58.21.mov2026-01-27.14.59.01.mov2026-01-27.14.59.35.movAndroid: mWeb Chrome2026-01-27.14.58.21.mov2026-01-27.14.59.01.mov2026-01-27.14.59.35.moviOS: HybridApp2026-01-27.14.22.21.mov2026-01-27.14.24.38.mov2026-01-27.14.25.24.moviOS: mWeb Safari2026-01-27.14.29.52.mov2026-01-27.14.26.54.mov2026-01-27.14.55.16.movMacOS: Chrome / Safari2026-01-27.14.10.15.mov2026-01-27.14.13.45.mov2026-01-27.14.16.00.mov |
|
LGTM! |
| const confirmModalPrompt = isTrackingGPS ? translate('gps.signOutWarningTripInProgress.prompt') : translate('initialSettingsPage.signOutConfirmationText'); | ||
| const confirmModalConfirmText = isTrackingGPS ? translate('gps.signOutWarningTripInProgress.confirm') : translate('initialSettingsPage.signOut'); | ||
|
|
||
| const showSignOutModal = useCallback(() => { |
There was a problem hiding this comment.
We don't need useCallback here
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/roryabraham in version: 9.3.11-0 🚀
|
|
🚀 Deployed to production by https://github.com/Julesssss in version: 9.3.12-1 🚀
|
Explanation of Change
Fixed Issues
$ #76693
PROPOSAL:
Tests
Test 1: EnabledPage
Requirement: Account has 2fa + Has any workspace connect to xero
Test 2: LockAccountPage
Test 3: InitialSettingsPage
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Screen.Recording.2026-01-15.at.18.43.42.mov
Android: mWeb Chrome
Screen.Recording.2026-01-15.at.18.39.47.mov
iOS: Native
Screen.Recording.2026-01-15.at.18.43.02.mov
iOS: mWeb Safari
Screen.Recording.2026-01-15.at.18.41.49.mov
MacOS: Chrome / Safari
TwoFactorAuth/DisablePage.tsx
TwoFactorAuth/EnabledPage.tsx
Screen.Recording.2025-12-10.at.01.17.47.mov
LockAccountPage.tsx
Screen.Recording.2025-12-10.at.01.18.41.mov
InitialSettingsPage.tsx
Screen.Recording.2025-12-10.at.01.19.44.mov