Skip to content

Commit bfe20fd

Browse files
committed
fix: apply selector to useOnyx
1 parent 6846021 commit bfe20fd

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/pages/home/report/ReportActionItemParentAction.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,23 @@ function ReportActionItemParentAction({
8383
const [allAncestors, setAllAncestors] = useState<Ancestor[]>([]);
8484
const {isOffline} = useNetwork();
8585
const {isInNarrowPaneModal} = useResponsiveLayout();
86-
const [reportNameValuePairs] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, {canBeMissing: true});
86+
const [reportNameValuePairs] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, {
87+
canBeMissing: true,
88+
selector: (allPairs) => {
89+
const ancestorIDsToSelect = new Set(allAncestors.map(({report: reportAncestor}) => reportAncestor.reportID));
90+
91+
return Object.entries(allPairs ?? {}).reduce(
92+
(acc, [key, value]) => {
93+
const id = key.split('_').at(1);
94+
if (ancestorIDsToSelect.has(id ?? '')) {
95+
acc[key] = value;
96+
}
97+
return acc;
98+
},
99+
{} as Record<string, unknown>,
100+
);
101+
},
102+
});
87103

88104
useEffect(() => {
89105
const unsubscribeReports: Array<() => void> = [];

0 commit comments

Comments
 (0)