From bc6fcb1ef71f51de45f693daca27411113becd06 Mon Sep 17 00:00:00 2001 From: DylanDylann <141406735+DylanDylann@users.noreply.github.com> Date: Wed, 22 Apr 2026 13:40:55 +0700 Subject: [PATCH] Revert "Using ReportID from route" --- .../MoneyRequestReportActionsList.tsx | 14 ++++++++------ .../MoneyRequestReportView.tsx | 5 ++++- src/pages/inbox/ReportActionsList.tsx | 4 ++-- src/pages/inbox/report/ReportFooter.tsx | 8 ++++---- ...oneyRequestReportActionsListRejectModalTest.tsx | 12 +++++++----- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx index ded3a7d9f439..8cdf1a25a6ad 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx @@ -80,11 +80,14 @@ const DELAY_FOR_SCROLLING_TO_END = 100; const BACKFILL_MIN_ACTIONS_THRESHOLD = 50; type MoneyRequestReportListProps = { + /** The reportID of the report to display */ + reportID: string | undefined; + /** Callback executed on layout */ onLayout?: (event: LayoutChangeEvent) => void; }; -function MoneyRequestReportActionsList({onLayout}: MoneyRequestReportListProps) { +function MoneyRequestReportActionsList({reportID: reportIDProp, onLayout}: MoneyRequestReportListProps) { const styles = useThemeStyles(); const {translate, getLocalDateFromDatetime} = useLocalize(); const {isOffline, lastOfflineAt, lastOnlineAt} = useNetworkWithOfflineStatus(); @@ -94,19 +97,18 @@ function MoneyRequestReportActionsList({onLayout}: MoneyRequestReportListProps) const [isVisible, setIsVisible] = useState(Visibility.isVisible); const isFocused = useIsFocused(); const route = useRoute>(); - const reportIDFromRoute = route.params.reportID; // Self-subscribe to report, policy, metadata, actions, transactions // report is guaranteed to exist — callers only render this component when report is loaded - const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportIDFromRoute}`) as unknown as [OnyxTypes.Report]; + const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportIDProp}`) as unknown as [OnyxTypes.Report]; const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${getNonEmptyStringOnyxID(report?.policyID)}`); - const [reportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportIDFromRoute}`); + const [reportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportIDProp}`); const reportID = report?.reportID; const {reportActions: unfilteredReportActions, hasNewerActions, hasOlderActions} = usePaginatedReportActions(reportID, route?.params?.reportActionID); const reportActions = useMemo(() => getFilteredReportActionsForReportView(unfilteredReportActions), [unfilteredReportActions]); - const allReportTransactions = useReportTransactionsCollection(reportIDFromRoute); + const allReportTransactions = useReportTransactionsCollection(reportIDProp); const reportTransactions = useMemo(() => getAllNonDeletedTransactions(allReportTransactions, reportActions, isOffline, true), [allReportTransactions, reportActions, isOffline]); const transactions = useMemo( () => reportTransactions?.filter((transaction) => isOffline || transaction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) ?? [], @@ -670,7 +672,7 @@ function MoneyRequestReportActionsList({onLayout}: MoneyRequestReportListProps) ref={wrapperViewRef} > diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx index a216c445f66f..6f793c2f6375 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx @@ -273,7 +273,10 @@ function MoneyRequestReportView({report, reportMetadata, shouldDisplayReportFoot )} {shouldDisplayMoneyRequestActionsList ? ( - + ) : ( ; + return ; } - return ; + return ; } export default ReportActionsList; diff --git a/src/pages/inbox/report/ReportFooter.tsx b/src/pages/inbox/report/ReportFooter.tsx index ea884f51392f..10dbc816528c 100644 --- a/src/pages/inbox/report/ReportFooter.tsx +++ b/src/pages/inbox/report/ReportFooter.tsx @@ -80,7 +80,7 @@ function ReportFooter() { const isSystemChat = isSystemChatUtil(report); const isAdminsOnlyPostingRoom = isAdminsOnlyPostingRoomUtil(report); - if (!isCurrentReportLoadedFromOnyx || !report || !reportIDFromRoute) { + if (!isCurrentReportLoadedFromOnyx || !report) { return null; } @@ -91,7 +91,7 @@ function ReportFooter() { return ( - + ); @@ -101,7 +101,7 @@ function ReportFooter() { if (isArchivedRoom) { return ( - + {!shouldUseNarrowLayout && ( @@ -115,7 +115,7 @@ function ReportFooter() { if (isAnonymousUser) { return ( - + {!shouldUseNarrowLayout && ( diff --git a/tests/ui/MoneyRequestReportActionsListRejectModalTest.tsx b/tests/ui/MoneyRequestReportActionsListRejectModalTest.tsx index f0937f790cda..3ce3f714eecf 100644 --- a/tests/ui/MoneyRequestReportActionsListRejectModalTest.tsx +++ b/tests/ui/MoneyRequestReportActionsListRejectModalTest.tsx @@ -26,9 +26,7 @@ jest.mock('@react-navigation/native', () => ({ useNavigationState: () => true, usePreventRemove: jest.fn(), useRoute: () => ({ - key: 'test-key', - name: 'Report' as never, - params: {reportID: FAKE_REPORT_ID}, + params: {}, }), })); @@ -196,7 +194,7 @@ const renderComponent = () => { - + , @@ -212,13 +210,17 @@ describe('MoneyRequestReportActionsList - Reject Educational Modal', () => { keys: ONYXKEYS, evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }); + jest.spyOn(NativeNavigation, 'useRoute').mockReturnValue({ + key: 'test-key', + name: 'Report' as never, + params: {reportID: FAKE_REPORT_ID}, + }); jest.spyOn(NativeNavigation, 'useIsFocused').mockReturnValue(true); await TestHelper.signInWithTestUser(FAKE_ACCOUNT_ID, FAKE_EMAIL); }); beforeEach(async () => { jest.clearAllMocks(); - jest.spyOn(NativeNavigation, 'useIsFocused').mockReturnValue(true); await act(async () => { await Onyx.clear(); await waitForBatchedUpdatesWithAct();