diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 06bc223ca181..a019773b2f19 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -1452,9 +1452,9 @@ function lockAccount(accountID?: number, domainAccountID?: number, domainName?: return API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.LOCK_ACCOUNT, params, {optimisticData, successData, failureData}); } -function requestUnlockAccount(accountID?: number) { +function requestUnlockAccount(accountID: number) { const params: LockAccountParams = { - accountID: accountID ?? currentUserAccountID, + accountID, }; API.write(WRITE_COMMANDS.REQUEST_UNLOCK_ACCOUNT, params); diff --git a/src/pages/settings/Security/LockAccount/UnlockAccountPage.tsx b/src/pages/settings/Security/LockAccount/UnlockAccountPage.tsx index 3a03008c9909..85438f1d22b2 100644 --- a/src/pages/settings/Security/LockAccount/UnlockAccountPage.tsx +++ b/src/pages/settings/Security/LockAccount/UnlockAccountPage.tsx @@ -3,6 +3,7 @@ import ConfirmationPage from '@components/ConfirmationPage'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -12,6 +13,7 @@ import ROUTES from '@src/ROUTES'; function UnlockAccountPage() { const {translate} = useLocalize(); + const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const styles = useThemeStyles(); const icons = useMemoizedLazyExpensifyIcons(['EmptyStateSpyPigeon']); @@ -33,7 +35,7 @@ function UnlockAccountPage() { descriptionStyle={styles.colorMuted} buttonText={translate('unlockAccountPage.chatWithConcierge')} onButtonPress={() => { - requestUnlockAccount(); + requestUnlockAccount(currentUserPersonalDetails.accountID); Navigation.navigate(ROUTES.CONCIERGE); }} containerStyle={styles.h100} diff --git a/tests/actions/UserTest.ts b/tests/actions/UserTest.ts index 06ab7f9635c8..23f137a56789 100644 --- a/tests/actions/UserTest.ts +++ b/tests/actions/UserTest.ts @@ -798,17 +798,6 @@ describe('actions/User', () => { expect(mockAPI.write).toHaveBeenCalledWith(WRITE_COMMANDS.REQUEST_UNLOCK_ACCOUNT, {accountID}); }); - - it('should fall back to currentUserAccountID when no accountID is provided', async () => { - const currentAccountID = 888; - await Onyx.merge(ONYXKEYS.SESSION, {accountID: currentAccountID, email: 'user@expensify.com'}); - await waitForBatchedUpdates(); - - UserActions.requestUnlockAccount(); - await waitForBatchedUpdates(); - - expect(mockAPI.write).toHaveBeenCalledWith(WRITE_COMMANDS.REQUEST_UNLOCK_ACCOUNT, {accountID: currentAccountID}); - }); }); describe('respondToProactiveAppReview', () => {