From 56bff81933b313f72494ec36da7fffe31d18437f Mon Sep 17 00:00:00 2001 From: truph01 Date: Mon, 27 Apr 2026 09:47:03 +0700 Subject: [PATCH 1/5] fix: Remove Onyx.connect() for the key: ONYXKEYS.COLLECTION.POLICY --- src/pages/iou/request/step/BaseRequestStepWorkspace.tsx | 5 +++-- src/pages/iou/request/step/IOURequestEditReport.tsx | 6 +++--- src/pages/iou/request/step/IOURequestEditReportCommon.tsx | 3 ++- src/pages/iou/request/step/IOURequestStepDestination.tsx | 2 +- src/pages/iou/request/step/IOURequestStepHours.tsx | 4 ++-- src/pages/iou/request/step/IOURequestStepReport.tsx | 6 +++--- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/pages/iou/request/step/BaseRequestStepWorkspace.tsx b/src/pages/iou/request/step/BaseRequestStepWorkspace.tsx index f8c09a24a70a..2990e18de912 100644 --- a/src/pages/iou/request/step/BaseRequestStepWorkspace.tsx +++ b/src/pages/iou/request/step/BaseRequestStepWorkspace.tsx @@ -81,11 +81,12 @@ function BaseRequestStepWorkspace({transaction, getPolicies, onSelectWorkspace}: const selectWorkspace = (item: WorkspaceListItem) => { const policyID = item.policyID; - if (shouldRestrictUserBillableActions(policyID, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + const selectedPolicy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]; + if (selectedPolicy && shouldRestrictUserBillableActions(selectedPolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policyID)); return; } - onSelectWorkspace(allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]); + onSelectWorkspace(selectedPolicy); }; return ( diff --git a/src/pages/iou/request/step/IOURequestEditReport.tsx b/src/pages/iou/request/step/IOURequestEditReport.tsx index 27a7e1439a9d..3ca822fb3954 100644 --- a/src/pages/iou/request/step/IOURequestEditReport.tsx +++ b/src/pages/iou/request/step/IOURequestEditReport.tsx @@ -138,9 +138,9 @@ function IOURequestEditReport({route}: IOURequestEditReportProps) { }); const createReport = () => { - const restrictionPolicyID = hasPerDiemTransactions ? selectedReport?.policyID : policyForMovingExpensesID; - if (restrictionPolicyID && shouldRestrictUserBillableActions(restrictionPolicyID, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { - Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(restrictionPolicyID)); + const restrictionPolicy = hasPerDiemTransactions ? selectedReportPolicy : policyForMovingExpenses; + if (restrictionPolicy && shouldRestrictUserBillableActions(restrictionPolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(restrictionPolicy.id)); return; } if (hasPerDiemTransactions) { diff --git a/src/pages/iou/request/step/IOURequestEditReportCommon.tsx b/src/pages/iou/request/step/IOURequestEditReportCommon.tsx index d8772eb1ac97..3ba4f68c339b 100644 --- a/src/pages/iou/request/step/IOURequestEditReportCommon.tsx +++ b/src/pages/iou/request/step/IOURequestEditReportCommon.tsx @@ -228,7 +228,8 @@ function IOURequestEditReportCommon({ return; } - if (item?.policyID && shouldRestrictUserBillableActions(item.policyID, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + const itemPolicy = item.policyID ? allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${item.policyID}`] : undefined; + if (item?.policyID && itemPolicy && shouldRestrictUserBillableActions(itemPolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(item.policyID)); return; } diff --git a/src/pages/iou/request/step/IOURequestStepDestination.tsx b/src/pages/iou/request/step/IOURequestStepDestination.tsx index 025f2e0224ae..3f3ccc5f1c3f 100644 --- a/src/pages/iou/request/step/IOURequestStepDestination.tsx +++ b/src/pages/iou/request/step/IOURequestStepDestination.tsx @@ -109,7 +109,7 @@ function IOURequestStepDestination({ }; const updateDestination = (destination: ListItem & {currency: string}) => { - if (openedFromStartPage && policy?.id && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + if (openedFromStartPage && policy && shouldRestrictUserBillableActions(policy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } diff --git a/src/pages/iou/request/step/IOURequestStepHours.tsx b/src/pages/iou/request/step/IOURequestStepHours.tsx index 497792adaa44..053fbcfb4e53 100644 --- a/src/pages/iou/request/step/IOURequestStepHours.tsx +++ b/src/pages/iou/request/step/IOURequestStepHours.tsx @@ -167,8 +167,8 @@ function IOURequestStepHours({ large={!isExtraSmallScreenHeight} style={[styles.w100, canUseTouchScreen ? styles.mt5 : styles.mt0]} onPress={() => { - if (policyID && shouldRestrictUserBillableActions(policyID, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { - Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policyID)); + if (policy && shouldRestrictUserBillableActions(policy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } saveTime(); diff --git a/src/pages/iou/request/step/IOURequestStepReport.tsx b/src/pages/iou/request/step/IOURequestStepReport.tsx index 27d62f645c26..5580163d231a 100644 --- a/src/pages/iou/request/step/IOURequestStepReport.tsx +++ b/src/pages/iou/request/step/IOURequestStepReport.tsx @@ -259,9 +259,9 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) { }); const createReport = () => { - const restrictionPolicyID = isPerDiemTransaction ? perDiemOriginalPolicy?.id : policyForMovingExpensesID; - if (restrictionPolicyID && shouldRestrictUserBillableActions(restrictionPolicyID, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { - Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(restrictionPolicyID)); + const restrictionPolicy = isPerDiemTransaction ? perDiemOriginalPolicy : policyForMovingExpenses; + if (restrictionPolicy && shouldRestrictUserBillableActions(restrictionPolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(restrictionPolicy.id)); return; } if (isPerDiemTransaction) { From 6f6a2eabb33dffd81ed4d6a68ad8bfad8d190926 Mon Sep 17 00:00:00 2001 From: truph01 Date: Mon, 27 Apr 2026 10:15:42 +0700 Subject: [PATCH 2/5] fix: refactor more files --- src/hooks/useParticipantSubmission.ts | 2 +- .../ReportActionCompose/useAttachmentUploadValidation.ts | 2 +- src/pages/inbox/sidebar/FABPopoverContent/useScanActions.ts | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hooks/useParticipantSubmission.ts b/src/hooks/useParticipantSubmission.ts index 2d3c08ee05b6..0ae04219910d 100644 --- a/src/hooks/useParticipantSubmission.ts +++ b/src/hooks/useParticipantSubmission.ts @@ -98,7 +98,7 @@ function useParticipantSubmission({ iouType === CONST.IOU.TYPE.CREATE && isPaidGroupPolicy(activePolicy) && activePolicy?.isPolicyExpenseChatEnabled && - !shouldRestrictUserBillableActions(activePolicy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed); + !shouldRestrictUserBillableActions(activePolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed); const dataRef = useRef({ allPolicies, diff --git a/src/pages/inbox/report/ReportActionCompose/useAttachmentUploadValidation.ts b/src/pages/inbox/report/ReportActionCompose/useAttachmentUploadValidation.ts index ef6a55969a36..d60ee74fa364 100644 --- a/src/pages/inbox/report/ReportActionCompose/useAttachmentUploadValidation.ts +++ b/src/pages/inbox/report/ReportActionCompose/useAttachmentUploadValidation.ts @@ -185,7 +185,7 @@ function useAttachmentUploadValidation({ const onReceiptDropped = useCallback( (e: DragEvent) => { - if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + if (policy && shouldRestrictUserBillableActions(policy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } diff --git a/src/pages/inbox/sidebar/FABPopoverContent/useScanActions.ts b/src/pages/inbox/sidebar/FABPopoverContent/useScanActions.ts index c4b88cde456d..bffea152f8b1 100644 --- a/src/pages/inbox/sidebar/FABPopoverContent/useScanActions.ts +++ b/src/pages/inbox/sidebar/FABPopoverContent/useScanActions.ts @@ -2,6 +2,7 @@ import {useState} from 'react'; import type {OnyxCollection} from 'react-native-onyx'; import useOnyx from '@hooks/useOnyx'; import {startMoneyRequest} from '@libs/actions/IOU'; +import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID'; import interceptAnonymousUser from '@libs/interceptAnonymousUser'; import Navigation from '@libs/Navigation/Navigation'; import {generateReportID, getWorkspaceChats} from '@libs/ReportUtils'; @@ -50,10 +51,11 @@ function useScanActions() { const policyChatPolicyID = policyChatForActivePolicy?.policyID; const policyChatReportID = policyChatForActivePolicy?.reportID; + const [policyChatPolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${getNonEmptyStringOnyxID(policyChatForActivePolicy?.policyID)}`); const startQuickScan = () => { interceptAnonymousUser(() => { - if (policyChatPolicyID && shouldRestrictUserBillableActions(policyChatPolicyID, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + if (policyChatPolicyID && policyChatPolicy && shouldRestrictUserBillableActions(policyChatPolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policyChatPolicyID)); return; } From 838009e4485dfa33cb75aee34c63bbd5b5664bc1 Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 28 Apr 2026 15:05:06 +0700 Subject: [PATCH 3/5] fix: conflicts --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 7639cf734a06..becf1561d1f2 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 7639cf734a06b7e3f1a0a0fcd3179c851fc34e69 +Subproject commit becf1561d1f25f92bc08456841885116bfa1041f From 674a70ee4676e49899a51be33dd5d2cd981c895f Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 28 Apr 2026 15:08:03 +0700 Subject: [PATCH 4/5] fix: conflicts --- src/pages/inbox/report/ReportActionCompose/useReceiptDrop.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/inbox/report/ReportActionCompose/useReceiptDrop.ts b/src/pages/inbox/report/ReportActionCompose/useReceiptDrop.ts index 8fd819024412..ce2ad801464a 100644 --- a/src/pages/inbox/report/ReportActionCompose/useReceiptDrop.ts +++ b/src/pages/inbox/report/ReportActionCompose/useReceiptDrop.ts @@ -88,7 +88,7 @@ function useReceiptDrop({reportID, report, shouldAddOrReplaceReceipt, transactio const {validateFiles, PDFValidationComponent, ErrorModal} = useFilesValidation(onFilesValidated); const onReceiptDropped = (e: DragEvent) => { - if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + if (policy && shouldRestrictUserBillableActions(policy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } From f898ba6b4cae60f35e3ab9d5b9ddc7bdf13b0541 Mon Sep 17 00:00:00 2001 From: truph01 Date: Fri, 1 May 2026 22:58:37 +0700 Subject: [PATCH 5/5] fix: conflicts --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index becf1561d1f2..d62f51382590 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit becf1561d1f25f92bc08456841885116bfa1041f +Subproject commit d62f5138259092bd8838fbc8eadff12372768fe4