From fb20e1c9292f48ddadae9d99b64f7f6998e29b04 Mon Sep 17 00:00:00 2001 From: Hans Date: Wed, 15 Apr 2026 23:18:22 +0700 Subject: [PATCH 1/6] update shouldRestrictUserBillableActions usages part 1 --- .../BaseFloatingCameraButton.tsx | 2 +- src/components/MoneyReportHeader.tsx | 2 +- .../SearchMoneyRequestReportEmptyState.tsx | 7 ++++--- .../QuickCreationActionsBar/index.tsx | 21 +++++++++++++++++-- .../SearchActionsBarCreateButton.tsx | 21 +++++++++++++++++-- src/components/SettlementButton/index.tsx | 2 +- src/hooks/useReceiptScanDrop.tsx | 2 +- src/libs/SubscriptionUtils.ts | 3 ++- 8 files changed, 48 insertions(+), 12 deletions(-) diff --git a/src/components/FloatingCameraButton/BaseFloatingCameraButton.tsx b/src/components/FloatingCameraButton/BaseFloatingCameraButton.tsx index 1b751e7a9d95..536e8a50f352 100644 --- a/src/components/FloatingCameraButton/BaseFloatingCameraButton.tsx +++ b/src/components/FloatingCameraButton/BaseFloatingCameraButton.tsx @@ -62,7 +62,7 @@ function BaseFloatingCameraButton({icon}: BaseFloatingCameraButtonProps) { interceptAnonymousUser(() => { if ( policyChatForActivePolicy?.policyID && - shouldRestrictUserBillableActions(policyChatForActivePolicy.policyID, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, activePolicy) + shouldRestrictUserBillableActions(policyChatForActivePolicy.policyID, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, activePolicy, session?.accountID) ) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policyChatForActivePolicy.policyID)); return; diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index dfa5f1e22750..ab8886be1032 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -1781,7 +1781,7 @@ function MoneyReportHeaderContent({reportID: reportIDProp, shouldDisplayBackButt if (!moneyRequestReport?.reportID) { return; } - if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy)) { + if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy, accountID)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } diff --git a/src/components/MoneyRequestReportView/SearchMoneyRequestReportEmptyState.tsx b/src/components/MoneyRequestReportView/SearchMoneyRequestReportEmptyState.tsx index 2f7f89548767..6c23ddea0e2e 100644 --- a/src/components/MoneyRequestReportView/SearchMoneyRequestReportEmptyState.tsx +++ b/src/components/MoneyRequestReportView/SearchMoneyRequestReportEmptyState.tsx @@ -21,6 +21,7 @@ import type * as OnyxTypes from '@src/types/onyx'; const minModalHeight = 380; function SearchMoneyRequestReportEmptyState({report, policy, onLayout}: {report: OnyxTypes.Report; policy?: OnyxTypes.Policy; onLayout?: (event: LayoutChangeEvent) => void}) { + const [session] = useOnyx(ONYXKEYS.SESSION); const [userBillingGracePeriodEnds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END); const [ownerBillingGracePeriodEnd] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END); const [amountOwed] = useOnyx(ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED); @@ -44,7 +45,7 @@ function SearchMoneyRequestReportEmptyState({report, policy, onLayout}: {report: if (!reportId) { return; } - if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy)) { + if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy, session?.accountID)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } @@ -59,7 +60,7 @@ function SearchMoneyRequestReportEmptyState({report, policy, onLayout}: {report: if (!reportId) { return; } - if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy)) { + if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy, session?.accountID)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } @@ -71,7 +72,7 @@ function SearchMoneyRequestReportEmptyState({report, policy, onLayout}: {report: text: translate('iou.addUnreportedExpense'), icon: icons.ReceiptPlus, onSelected: () => { - if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy)) { + if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy, session?.accountID)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } diff --git a/src/components/Navigation/QuickCreationActionsBar/index.tsx b/src/components/Navigation/QuickCreationActionsBar/index.tsx index ebdc1656e6f6..5ae309a91b97 100644 --- a/src/components/Navigation/QuickCreationActionsBar/index.tsx +++ b/src/components/Navigation/QuickCreationActionsBar/index.tsx @@ -176,14 +176,30 @@ function QuickCreationActionsBar() { if ( !workspaceIDForReportCreation || - (shouldRestrictUserBillableActions(workspaceIDForReportCreation, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, undefined, defaultChatEnabledPolicy) && + (shouldRestrictUserBillableActions( + workspaceIDForReportCreation, + ownerBillingGracePeriodEnd, + userBillingGracePeriodEnds, + undefined, + defaultChatEnabledPolicy, + session?.accountID, + ) && groupPoliciesWithChatEnabled.length > 1) ) { Navigation.navigate(ROUTES.NEW_REPORT_WORKSPACE_SELECTION.getRoute()); return; } - if (!shouldRestrictUserBillableActions(workspaceIDForReportCreation, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, undefined, defaultChatEnabledPolicy)) { + if ( + !shouldRestrictUserBillableActions( + workspaceIDForReportCreation, + ownerBillingGracePeriodEnd, + userBillingGracePeriodEnds, + undefined, + defaultChatEnabledPolicy, + session?.accountID, + ) + ) { if (shouldShowEmptyReportConfirmationForDefaultChatEnabledPolicy) { openCreateReportConfirmation(); } else { @@ -206,6 +222,7 @@ function QuickCreationActionsBar() { shouldShowEmptyReportConfirmationForDefaultChatEnabledPolicy, openCreateReportConfirmation, handleCreateWorkspaceReport, + session?.accountID, ], ); diff --git a/src/components/Search/SearchPageHeader/SearchActionsBarCreateButton.tsx b/src/components/Search/SearchPageHeader/SearchActionsBarCreateButton.tsx index f0ff7e5c994d..1e72c5abb2eb 100644 --- a/src/components/Search/SearchPageHeader/SearchActionsBarCreateButton.tsx +++ b/src/components/Search/SearchPageHeader/SearchActionsBarCreateButton.tsx @@ -186,7 +186,14 @@ function SearchActionsBarCreateButton() { // No default or restricted with multiple workspaces → workspace selector if ( !workspaceIDForReportCreation || - (shouldRestrictUserBillableActions(workspaceIDForReportCreation, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed) && + (shouldRestrictUserBillableActions( + workspaceIDForReportCreation, + ownerBillingGracePeriodEnd, + userBillingGracePeriodEnds, + amountOwed, + undefined, + session?.accountID, + ) && groupPoliciesWithChatEnabled.length > 1) ) { Navigation.navigate(ROUTES.NEW_REPORT_WORKSPACE_SELECTION.getRoute()); @@ -194,7 +201,16 @@ function SearchActionsBarCreateButton() { } // Default workspace is not restricted → create report directly - if (!shouldRestrictUserBillableActions(workspaceIDForReportCreation, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + if ( + !shouldRestrictUserBillableActions( + workspaceIDForReportCreation, + ownerBillingGracePeriodEnd, + userBillingGracePeriodEnds, + amountOwed, + undefined, + session?.accountID, + ) + ) { // Check if empty report confirmation should be shown if (shouldShowEmptyReportConfirmationForDefaultChatEnabledPolicy) { openCreateReportConfirmation(); @@ -223,6 +239,7 @@ function SearchActionsBarCreateButton() { openCreateReportConfirmation, handleCreateWorkspaceReport, amountOwed, + session?.accountID, ], ); diff --git a/src/components/SettlementButton/index.tsx b/src/components/SettlementButton/index.tsx index ecf8dbd95108..be756e0c6415 100644 --- a/src/components/SettlementButton/index.tsx +++ b/src/components/SettlementButton/index.tsx @@ -224,7 +224,7 @@ function SettlementButton({ return true; } - if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy)) { + if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy, currentUserAccountID)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return true; } diff --git a/src/hooks/useReceiptScanDrop.tsx b/src/hooks/useReceiptScanDrop.tsx index 7dd7da8c3d9c..81410c95ade6 100644 --- a/src/hooks/useReceiptScanDrop.tsx +++ b/src/hooks/useReceiptScanDrop.tsx @@ -82,7 +82,7 @@ function useReceiptScanDrop() { if ( isPaidGroupPolicy(activePolicy) && activePolicy?.isPolicyExpenseChatEnabled && - !shouldRestrictUserBillableActions(activePolicy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, activePolicy) + !shouldRestrictUserBillableActions(activePolicy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, activePolicy, currentUserPersonalDetails.accountID) ) { const shouldAutoReport = !!activePolicy?.autoReporting || !!personalPolicy?.autoReporting; const report = shouldAutoReport ? getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id) : selfDMReport; diff --git a/src/libs/SubscriptionUtils.ts b/src/libs/SubscriptionUtils.ts index fb67a0682599..cfa5c762b7fa 100644 --- a/src/libs/SubscriptionUtils.ts +++ b/src/libs/SubscriptionUtils.ts @@ -465,6 +465,7 @@ function shouldRestrictUserBillableActions( userBillingGracePeriodEnds: OnyxCollection, amountOwed: OnyxEntry = privateAmountOwed, policy: OnyxEntry = deprecatedAllPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`], + currentUserAccountID?: number, ): boolean { const currentDate = new Date(); @@ -487,7 +488,7 @@ function shouldRestrictUserBillableActions( // If it reached here it means that the user is actually the workspace's owner. // We should restrict the workspace's owner actions if it's past its grace period end date and it's owing some amount. if ( - isPolicyOwner(policy, deprecatedCurrentUserAccountID) && + isPolicyOwner(policy, currentUserAccountID ?? deprecatedCurrentUserAccountID) && ownerBillingGracePeriodEnd && amountOwed !== undefined && amountOwed > 0 && From 66b56b54580b2e9dd7a59c92b0a567088bbc3ade Mon Sep 17 00:00:00 2001 From: "Hans (via MelvinBot)" Date: Wed, 15 Apr 2026 17:10:41 +0000 Subject: [PATCH 2/6] Revert Mobile-Expensify submodule change Co-authored-by: Hans --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 678b3bb85709..d10f5855820f 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 678b3bb8570967dcf4c16a323f747e83fd96e7f0 +Subproject commit d10f5855820ff5fe53fd1a4564434d2eb8152efe From d50ea047a833fdfd9ab8e9a430c307312d2d2c68 Mon Sep 17 00:00:00 2001 From: Hans Date: Thu, 16 Apr 2026 00:11:54 +0700 Subject: [PATCH 3/6] revert submodule --- Mobile-Expensify | 2 +- .../SearchMoneyRequestReportEmptyState.tsx | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 678b3bb85709..d10f5855820f 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 678b3bb8570967dcf4c16a323f747e83fd96e7f0 +Subproject commit d10f5855820ff5fe53fd1a4564434d2eb8152efe diff --git a/src/components/MoneyRequestReportView/SearchMoneyRequestReportEmptyState.tsx b/src/components/MoneyRequestReportView/SearchMoneyRequestReportEmptyState.tsx index 6c23ddea0e2e..02ae995a72a1 100644 --- a/src/components/MoneyRequestReportView/SearchMoneyRequestReportEmptyState.tsx +++ b/src/components/MoneyRequestReportView/SearchMoneyRequestReportEmptyState.tsx @@ -15,13 +15,14 @@ import {openUnreportedExpense} from '@userActions/Report'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; +import {accountIDSelector} from '@src/selectors/Session'; import {validTransactionDraftIDsSelector} from '@src/selectors/TransactionDraft'; import type * as OnyxTypes from '@src/types/onyx'; const minModalHeight = 380; function SearchMoneyRequestReportEmptyState({report, policy, onLayout}: {report: OnyxTypes.Report; policy?: OnyxTypes.Policy; onLayout?: (event: LayoutChangeEvent) => void}) { - const [session] = useOnyx(ONYXKEYS.SESSION); + const [accountID] = useOnyx(ONYXKEYS.SESSION, {selector: accountIDSelector}); const [userBillingGracePeriodEnds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END); const [ownerBillingGracePeriodEnd] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END); const [amountOwed] = useOnyx(ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED); @@ -45,7 +46,7 @@ function SearchMoneyRequestReportEmptyState({report, policy, onLayout}: {report: if (!reportId) { return; } - if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy, session?.accountID)) { + if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy, accountID)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } @@ -60,7 +61,7 @@ function SearchMoneyRequestReportEmptyState({report, policy, onLayout}: {report: if (!reportId) { return; } - if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy, session?.accountID)) { + if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy, accountID)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } @@ -72,7 +73,7 @@ function SearchMoneyRequestReportEmptyState({report, policy, onLayout}: {report: text: translate('iou.addUnreportedExpense'), icon: icons.ReceiptPlus, onSelected: () => { - if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy, session?.accountID)) { + if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy, accountID)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } From 257f731a7038e8450ab85095af4573ccf4c7b07f Mon Sep 17 00:00:00 2001 From: Hans Date: Thu, 16 Apr 2026 22:04:24 +0700 Subject: [PATCH 4/6] update optional params --- src/libs/SubscriptionUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/SubscriptionUtils.ts b/src/libs/SubscriptionUtils.ts index 3fb185f038b9..97b69b1c59e0 100644 --- a/src/libs/SubscriptionUtils.ts +++ b/src/libs/SubscriptionUtils.ts @@ -459,7 +459,7 @@ function shouldRestrictUserBillableActions( userBillingGracePeriodEnds: OnyxCollection, amountOwed: OnyxEntry, policy: OnyxEntry = deprecatedAllPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`], - currentUserAccountID?: number, + currentUserAccountID: number = deprecatedCurrentUserAccountID, ): boolean { const currentDate = new Date(); @@ -482,7 +482,7 @@ function shouldRestrictUserBillableActions( // If it reached here it means that the user is actually the workspace's owner. // We should restrict the workspace's owner actions if it's past its grace period end date and it's owing some amount. if ( - isPolicyOwner(policy, currentUserAccountID ?? deprecatedCurrentUserAccountID) && + isPolicyOwner(policy, currentUserAccountID) && ownerBillingGracePeriodEnd && amountOwed !== undefined && amountOwed > 0 && From 11c7b2c931aaa3cffce82d80b875d276d8886f92 Mon Sep 17 00:00:00 2001 From: Hans Date: Thu, 16 Apr 2026 22:14:28 +0700 Subject: [PATCH 5/6] address comments --- .../FloatingCameraButton/BaseFloatingCameraButton.tsx | 8 ++++---- .../SearchMoneyRequestReportEmptyState.tsx | 4 ++-- .../Navigation/QuickCreationActionsBar/index.tsx | 6 +++--- .../SearchPageHeader/SearchActionsBarCreateButton.tsx | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/FloatingCameraButton/BaseFloatingCameraButton.tsx b/src/components/FloatingCameraButton/BaseFloatingCameraButton.tsx index 536e8a50f352..1b5548b1bc2f 100644 --- a/src/components/FloatingCameraButton/BaseFloatingCameraButton.tsx +++ b/src/components/FloatingCameraButton/BaseFloatingCameraButton.tsx @@ -5,6 +5,7 @@ import Icon from '@components/Icon'; import {loadExpensifyIconsChunk} from '@components/Icon/ExpensifyIconLoader'; import {loadIllustrationsChunk} from '@components/Icon/IllustrationLoader'; import {PressableWithoutFeedback} from '@components/Pressable'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import useTheme from '@hooks/useTheme'; @@ -20,7 +21,6 @@ import Tab from '@userActions/Tab'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import {sessionEmailAndAccountIDSelector} from '@src/selectors/Session'; import {validTransactionDraftIDsSelector} from '@src/selectors/TransactionDraft'; import type * as OnyxTypes from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; @@ -34,6 +34,7 @@ function BaseFloatingCameraButton({icon}: BaseFloatingCameraButtonProps) { const {textLight} = useTheme(); const styles = useThemeStyles(); const {translate} = useLocalize(); + const {accountID} = useCurrentUserPersonalDetails(); useEffect(() => { loadIllustrationsChunk().catch(() => {}); @@ -42,7 +43,6 @@ function BaseFloatingCameraButton({icon}: BaseFloatingCameraButtonProps) { const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID); const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`); - const [session] = useOnyx(ONYXKEYS.SESSION, {selector: sessionEmailAndAccountIDSelector}); const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector}); const [userBillingGracePeriodEnds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END); const [ownerBillingGracePeriodEnd] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END); @@ -53,7 +53,7 @@ function BaseFloatingCameraButton({icon}: BaseFloatingCameraButtonProps) { if (isEmptyObject(activePolicy) || !activePolicy?.isPolicyExpenseChatEnabled) { return undefined; } - const policyChatsForActivePolicy = getWorkspaceChats(activePolicyID, [session?.accountID ?? CONST.DEFAULT_NUMBER_ID], reports); + const policyChatsForActivePolicy = getWorkspaceChats(activePolicyID, [accountID], reports); return policyChatsForActivePolicy.at(0); }; const [policyChatForActivePolicy] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {selector: policyChatForActivePolicySelector}); @@ -62,7 +62,7 @@ function BaseFloatingCameraButton({icon}: BaseFloatingCameraButtonProps) { interceptAnonymousUser(() => { if ( policyChatForActivePolicy?.policyID && - shouldRestrictUserBillableActions(policyChatForActivePolicy.policyID, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, activePolicy, session?.accountID) + shouldRestrictUserBillableActions(policyChatForActivePolicy.policyID, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, activePolicy, accountID) ) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policyChatForActivePolicy.policyID)); return; diff --git a/src/components/MoneyRequestReportView/SearchMoneyRequestReportEmptyState.tsx b/src/components/MoneyRequestReportView/SearchMoneyRequestReportEmptyState.tsx index 02ae995a72a1..45c2d194d3e8 100644 --- a/src/components/MoneyRequestReportView/SearchMoneyRequestReportEmptyState.tsx +++ b/src/components/MoneyRequestReportView/SearchMoneyRequestReportEmptyState.tsx @@ -2,6 +2,7 @@ import React, {useEffect} from 'react'; import {View} from 'react-native'; import type {LayoutChangeEvent} from 'react-native'; import EmptyStateComponent from '@components/EmptyStateComponent'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import {useMemoizedLazyExpensifyIcons, useMemoizedLazyIllustrations} from '@hooks/useLazyAsset'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; @@ -15,14 +16,13 @@ import {openUnreportedExpense} from '@userActions/Report'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import {accountIDSelector} from '@src/selectors/Session'; import {validTransactionDraftIDsSelector} from '@src/selectors/TransactionDraft'; import type * as OnyxTypes from '@src/types/onyx'; const minModalHeight = 380; function SearchMoneyRequestReportEmptyState({report, policy, onLayout}: {report: OnyxTypes.Report; policy?: OnyxTypes.Policy; onLayout?: (event: LayoutChangeEvent) => void}) { - const [accountID] = useOnyx(ONYXKEYS.SESSION, {selector: accountIDSelector}); + const {accountID} = useCurrentUserPersonalDetails(); const [userBillingGracePeriodEnds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END); const [ownerBillingGracePeriodEnd] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END); const [amountOwed] = useOnyx(ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED); diff --git a/src/components/Navigation/QuickCreationActionsBar/index.tsx b/src/components/Navigation/QuickCreationActionsBar/index.tsx index 3bade5152ec8..661cc3744eb1 100644 --- a/src/components/Navigation/QuickCreationActionsBar/index.tsx +++ b/src/components/Navigation/QuickCreationActionsBar/index.tsx @@ -183,7 +183,7 @@ function QuickCreationActionsBar() { userBillingGracePeriodEnds, amountOwed, defaultChatEnabledPolicy, - session?.accountID, + currentUserPersonalDetails.accountID, ) && groupPoliciesWithChatEnabled.length > 1) ) { @@ -198,7 +198,7 @@ function QuickCreationActionsBar() { userBillingGracePeriodEnds, amountOwed, defaultChatEnabledPolicy, - session?.accountID, + currentUserPersonalDetails.accountID, ) ) { if (shouldShowEmptyReportConfirmationForDefaultChatEnabledPolicy) { @@ -224,7 +224,7 @@ function QuickCreationActionsBar() { shouldShowEmptyReportConfirmationForDefaultChatEnabledPolicy, openCreateReportConfirmation, handleCreateWorkspaceReport, - session?.accountID, + currentUserPersonalDetails.accountID, ], ); diff --git a/src/components/Search/SearchPageHeader/SearchActionsBarCreateButton.tsx b/src/components/Search/SearchPageHeader/SearchActionsBarCreateButton.tsx index 667f214287a4..e5133511f6d3 100644 --- a/src/components/Search/SearchPageHeader/SearchActionsBarCreateButton.tsx +++ b/src/components/Search/SearchPageHeader/SearchActionsBarCreateButton.tsx @@ -192,7 +192,7 @@ function SearchActionsBarCreateButton() { userBillingGracePeriodEnds, amountOwed, undefined, - session?.accountID, + currentUserPersonalDetails.accountID, ) && groupPoliciesWithChatEnabled.length > 1) ) { @@ -208,7 +208,7 @@ function SearchActionsBarCreateButton() { userBillingGracePeriodEnds, amountOwed, undefined, - session?.accountID, + currentUserPersonalDetails.accountID, ) ) { // Check if empty report confirmation should be shown @@ -239,7 +239,7 @@ function SearchActionsBarCreateButton() { openCreateReportConfirmation, handleCreateWorkspaceReport, amountOwed, - session?.accountID, + currentUserPersonalDetails.accountID, ], ); From 90892a91abfa910eb8d862902f6bca0e4beff5c9 Mon Sep 17 00:00:00 2001 From: Hans Date: Thu, 16 Apr 2026 23:00:20 +0700 Subject: [PATCH 6/6] fix tests --- tests/ui/components/SearchActionsBarCreateButtonTest.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/ui/components/SearchActionsBarCreateButtonTest.tsx b/tests/ui/components/SearchActionsBarCreateButtonTest.tsx index 8750049f6e1d..d46cdccd9ceb 100644 --- a/tests/ui/components/SearchActionsBarCreateButtonTest.tsx +++ b/tests/ui/components/SearchActionsBarCreateButtonTest.tsx @@ -3,6 +3,7 @@ import {getUnixTime, subDays} from 'date-fns'; import React from 'react'; import Onyx from 'react-native-onyx'; import ComposeProviders from '@components/ComposeProviders'; +import {CurrentUserPersonalDetailsProvider} from '@components/CurrentUserPersonalDetailsProvider'; import {LocaleContextProvider} from '@components/LocaleContextProvider'; import OnyxListItemProvider from '@components/OnyxListItemProvider'; import SearchActionsBarCreateButton from '@components/Search/SearchPageHeader/SearchActionsBarCreateButton'; @@ -76,7 +77,7 @@ const MOCK_POLICY = { function renderComponent() { return render( - + , );