From c3c647d293c7a0ea289f3f8d62b024b21872fa8d Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Fri, 20 Feb 2026 09:22:06 -0500 Subject: [PATCH 1/7] add selector --- .../inbox/sidebar/FloatingActionButtonAndPopover.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx index 0faa9d023b0f4..861c7b07d4b77 100644 --- a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx @@ -138,11 +138,20 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref const [quickAction] = useOnyx(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, {canBeMissing: true}); const [quickActionReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${quickAction?.chatReportID}`, {canBeMissing: true}); const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true}); - const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true}); const [allTransactionDrafts] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {canBeMissing: true}); const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`, {canBeMissing: true}); const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: true}); const {isRestrictedToPreferredPolicy, isRestrictedPolicyCreation} = usePreferredPolicy(); + + const workspaceChatsSelector = useCallback( + (reports: OnyxCollection) => { + return getWorkspaceChats(activePolicyID, [session?.accountID ?? CONST.DEFAULT_NUMBER_ID], reports); + }, + [activePolicyID, session?.accountID], + ); + + const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true}); + const policyChatForActivePolicy = useMemo(() => { if (isEmptyObject(activePolicy) || !activePolicy?.isPolicyExpenseChatEnabled) { return {} as OnyxTypes.Report; From b436b02910430efea7e810586db93c027eacdd9d Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Fri, 20 Feb 2026 09:22:36 -0500 Subject: [PATCH 2/7] use selctor --- src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx index 861c7b07d4b77..7377734f5055b 100644 --- a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx @@ -150,7 +150,10 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref [activePolicyID, session?.accountID], ); - const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true}); + const [policyChatsForActivePolicy] = useOnyx(ONYXKEYS.COLLECTION.REPORT, { + canBeMissing: true, + selector: workspaceChatsSelector, + }); const policyChatForActivePolicy = useMemo(() => { if (isEmptyObject(activePolicy) || !activePolicy?.isPolicyExpenseChatEnabled) { From c24ffeae864655b1d04ef349497404dd9edaf296 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Fri, 20 Feb 2026 09:24:30 -0500 Subject: [PATCH 3/7] apply the selector --- src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx index 7377734f5055b..5d498bc707f77 100644 --- a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx @@ -70,6 +70,7 @@ import {isTrackingSelector} from '@src/selectors/GPSDraftDetails'; import type * as OnyxTypes from '@src/types/onyx'; import type {QuickActionName} from '@src/types/onyx/QuickAction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; +import getEmptyArray from '@src/types/utils/getEmptyArray'; type PolicySelector = Pick; @@ -150,7 +151,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref [activePolicyID, session?.accountID], ); - const [policyChatsForActivePolicy] = useOnyx(ONYXKEYS.COLLECTION.REPORT, { + const [policyChatsForActivePolicy = getEmptyArray()] = useOnyx(ONYXKEYS.COLLECTION.REPORT, { canBeMissing: true, selector: workspaceChatsSelector, }); @@ -159,9 +160,8 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref if (isEmptyObject(activePolicy) || !activePolicy?.isPolicyExpenseChatEnabled) { return {} as OnyxTypes.Report; } - const policyChatsForActivePolicy = getWorkspaceChats(activePolicyID, [session?.accountID ?? CONST.DEFAULT_NUMBER_ID], allReports); return policyChatsForActivePolicy.length > 0 ? policyChatsForActivePolicy.at(0) : ({} as OnyxTypes.Report); - }, [activePolicy, activePolicyID, session?.accountID, allReports]); + }, [activePolicy, policyChatsForActivePolicy]); const quickActionPolicyID = quickAction?.action === CONST.QUICK_ACTIONS.TRACK_PER_DIEM && quickAction?.perDiemPolicyID ? quickAction?.perDiemPolicyID : quickActionReport?.policyID; const [quickActionPolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${quickActionPolicyID}`, {canBeMissing: true}); const [allPolicies] = useMappedPolicies(policyMapper); From 2aa516a84feb77c7241228a4393b0da430cddf09 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Fri, 20 Feb 2026 09:36:57 -0500 Subject: [PATCH 4/7] fix types --- src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx index 5d498bc707f77..adfaab5f337bf 100644 --- a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx @@ -67,7 +67,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import {isTrackingSelector} from '@src/selectors/GPSDraftDetails'; -import type * as OnyxTypes from '@src/types/onyx'; +import * as OnyxTypes from '@src/types/onyx'; import type {QuickActionName} from '@src/types/onyx/QuickAction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import getEmptyArray from '@src/types/utils/getEmptyArray'; @@ -151,7 +151,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref [activePolicyID, session?.accountID], ); - const [policyChatsForActivePolicy = getEmptyArray()] = useOnyx(ONYXKEYS.COLLECTION.REPORT, { + const [policyChatsForActivePolicy = getEmptyArray()] = useOnyx(ONYXKEYS.COLLECTION.REPORT, { canBeMissing: true, selector: workspaceChatsSelector, }); @@ -162,6 +162,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref } return policyChatsForActivePolicy.length > 0 ? policyChatsForActivePolicy.at(0) : ({} as OnyxTypes.Report); }, [activePolicy, policyChatsForActivePolicy]); + const quickActionPolicyID = quickAction?.action === CONST.QUICK_ACTIONS.TRACK_PER_DIEM && quickAction?.perDiemPolicyID ? quickAction?.perDiemPolicyID : quickActionReport?.policyID; const [quickActionPolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${quickActionPolicyID}`, {canBeMissing: true}); const [allPolicies] = useMappedPolicies(policyMapper); From c8a32622c2402f60f8977feb8bd8b2c06b4b14e0 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Fri, 20 Feb 2026 09:37:42 -0500 Subject: [PATCH 5/7] fix types --- src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx index adfaab5f337bf..5c0a6bd5a5329 100644 --- a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx @@ -67,7 +67,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import {isTrackingSelector} from '@src/selectors/GPSDraftDetails'; -import * as OnyxTypes from '@src/types/onyx'; +import type * as OnyxTypes from '@src/types/onyx'; import type {QuickActionName} from '@src/types/onyx/QuickAction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import getEmptyArray from '@src/types/utils/getEmptyArray'; From 6af5002cc3569fba1b27fd843f9b0bb9fe7e8449 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Fri, 20 Feb 2026 11:33:37 -0500 Subject: [PATCH 6/7] add deps --- src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx index 5c0a6bd5a5329..4e172e9eef2a1 100644 --- a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx @@ -151,10 +151,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref [activePolicyID, session?.accountID], ); - const [policyChatsForActivePolicy = getEmptyArray()] = useOnyx(ONYXKEYS.COLLECTION.REPORT, { - canBeMissing: true, - selector: workspaceChatsSelector, - }); + const [policyChatsForActivePolicy = getEmptyArray()] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {selector: workspaceChatsSelector}, [activePolicyID, session?.accountID]); const policyChatForActivePolicy = useMemo(() => { if (isEmptyObject(activePolicy) || !activePolicy?.isPolicyExpenseChatEnabled) { From 5fc2fba6e6d23047c12477228f4ca0106b92f2f8 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Fri, 20 Feb 2026 11:40:17 -0500 Subject: [PATCH 7/7] add back can be missing --- src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx index 4e172e9eef2a1..bd7403ca86144 100644 --- a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx @@ -151,7 +151,10 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref [activePolicyID, session?.accountID], ); - const [policyChatsForActivePolicy = getEmptyArray()] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {selector: workspaceChatsSelector}, [activePolicyID, session?.accountID]); + const [policyChatsForActivePolicy = getEmptyArray()] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true, selector: workspaceChatsSelector}, [ + activePolicyID, + session?.accountID, + ]); const policyChatForActivePolicy = useMemo(() => { if (isEmptyObject(activePolicy) || !activePolicy?.isPolicyExpenseChatEnabled) {