From 3fd4f376d09b2140ec985424936472c86286adf8 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 7 Jul 2026 14:27:14 +0800 Subject: [PATCH 1/4] start passing isReportActionsExist to openReport --- .../MoneyRequestReportActionsList.tsx | 2 +- src/hooks/useReportActionsScroll.ts | 2 +- src/libs/actions/Report/index.ts | 7 ++++- .../routes/TransactionReceiptModalContent.tsx | 3 ++- .../ReportAddAttachmentModalContent/index.tsx | 6 +++-- .../report/ReportAttachmentModalContent.tsx | 5 ++-- .../actions/IOUTest/DeleteMoneyRequestTest.ts | 6 +++++ tests/actions/IOUTest/DuplicateTest.ts | 2 ++ tests/actions/IOUTest/TrackExpenseTest.ts | 2 ++ tests/actions/MergeTransactionTest.ts | 2 ++ tests/actions/ReportTest.ts | 27 ++++++++++++------- 11 files changed, 46 insertions(+), 18 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx index 4a2eb35278d3..8066fe65db7b 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx @@ -619,7 +619,7 @@ function MoneyRequestReportActionsList({onLayout}: MoneyRequestReportListProps) setIsFloatingMessageCounterVisible(false); if (!hasNewestReportAction) { - openReport({reportID, introSelected, betas}); + openReport({reportID, introSelected, betas, isReportActionsExist: true}); reportScrollManager.scrollToEnd(); return; } diff --git a/src/hooks/useReportActionsScroll.ts b/src/hooks/useReportActionsScroll.ts index f277d6ecff7a..e286c632c542 100644 --- a/src/hooks/useReportActionsScroll.ts +++ b/src/hooks/useReportActionsScroll.ts @@ -334,7 +334,7 @@ function useReportActionsScroll({ if (!Navigation.getReportRHPActiveRoute()) { Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportID, undefined, undefined, backTo)); } - openReport({reportID, introSelected, betas}); + openReport({reportID, introSelected, betas, isReportActionsExist: true}); reportScrollManager.scrollToBottom(); return; } diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts index 9b72f3cf5500..02bc812d16db 100644 --- a/src/libs/actions/Report/index.ts +++ b/src/libs/actions/Report/index.ts @@ -360,6 +360,10 @@ type OpenReportActionParams = { // TODO: This will be required eventually. Refactor issue: https://github.com/Expensify/App/issues/66424 hasCompletedGuidedSetupFlow?: boolean; + /** Whether the report has report actions or not */ + // TODO: This will be required eventually. Refactor issue: https://github.com/Expensify/App/issues/73651 + isReportActionsExist?: boolean; + /** Beta features list */ betas: OnyxEntry; }; @@ -1482,6 +1486,7 @@ function openReport(params: OpenReportActionParams) { currentUserAccountID, isSelfTourViewed, hasCompletedGuidedSetupFlow, + isReportActionsExist, } = params; if (!reportID) { return; @@ -1492,7 +1497,7 @@ function openReport(params: OpenReportActionParams) { const participantAccountIDList = participants.map((p) => p.accountID).filter((id): id is number => id !== undefined); const existingReportName = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]?.reportName; const isCreatingNewReport = !isEmptyObject(newReportObject); - const optimisticReport: Partial> = reportActionsExist(reportID) || !existingReportName ? {} : {reportName: existingReportName}; + const optimisticReport: Partial> = (isReportActionsExist ?? reportActionsExist(reportID)) || !existingReportName ? {} : {reportName: existingReportName}; const optimisticData: Array< OnyxUpdate< diff --git a/src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx b/src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx index 3787ce3c11b5..2417c836edfd 100644 --- a/src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx +++ b/src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx @@ -63,6 +63,7 @@ function TransactionReceiptModalContent({navigation, route}: AttachmentModalScre const expensifyIcons = useMemoizedLazyExpensifyIcons(['Camera', 'Download', 'Crop', 'Trashcan', 'Rotate', 'Close', 'Checkmark']); const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`); + const [isReportActionsExist] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {selector: Boolean}); const allTransactions = useAllTransactions(); const transactionMain = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(transactionID)}`]; const [transactionDraft] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${getNonEmptyStringOnyxID(transactionID)}`); @@ -184,7 +185,7 @@ function TransactionReceiptModalContent({navigation, route}: AttachmentModalScre if ((!!report && !!transaction) || isDraftTransaction) { return; } - openReport({reportID, introSelected, betas}); + openReport({reportID, introSelected, betas, isReportActionsExist}); // I'm disabling the warning, as it expects to use exhaustive deps, even though we want this useEffect to run only on the first render. // eslint-disable-next-line react-hooks/exhaustive-deps }, []); diff --git a/src/pages/media/AttachmentModalScreen/routes/report/ReportAddAttachmentModalContent/index.tsx b/src/pages/media/AttachmentModalScreen/routes/report/ReportAddAttachmentModalContent/index.tsx index 4f3effad2963..2c78c2ed3db2 100644 --- a/src/pages/media/AttachmentModalScreen/routes/report/ReportAddAttachmentModalContent/index.tsx +++ b/src/pages/media/AttachmentModalScreen/routes/report/ReportAddAttachmentModalContent/index.tsx @@ -59,13 +59,15 @@ function ReportAddAttachmentModalContent({route, navigation}: AttachmentModalScr // Extract the reportActionID from the attachmentID (format: reportActionID_index) const reportActionID = useMemo(() => attachmentID?.split('_')?.[0], [attachmentID]); + const isReportActionsExist = !!reportActions; + const shouldFetchReport = useMemo(() => { return isEmptyObject(reportActions?.[reportActionID ?? CONST.DEFAULT_NUMBER_ID]); }, [reportActions, reportActionID]); const fetchReport = useCallback(() => { - openReport({reportID, introSelected, reportActionID, betas}); - }, [reportID, introSelected, reportActionID, betas]); + openReport({reportID, introSelected, reportActionID, betas, isReportActionsExist}); + }, [reportID, introSelected, reportActionID, betas, isReportActionsExist]); // Close the modal if user loses write access (e.g., admin switches "Who can post" to Admins only) useEffect(() => { diff --git a/src/pages/media/AttachmentModalScreen/routes/report/ReportAttachmentModalContent.tsx b/src/pages/media/AttachmentModalScreen/routes/report/ReportAttachmentModalContent.tsx index ec2018fe3aa9..b41ca407f42a 100644 --- a/src/pages/media/AttachmentModalScreen/routes/report/ReportAttachmentModalContent.tsx +++ b/src/pages/media/AttachmentModalScreen/routes/report/ReportAttachmentModalContent.tsx @@ -45,6 +45,7 @@ function ReportAttachmentModalContent({route, navigation}: AttachmentModalScreen } = route.params; const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`); + const isReportActionsExist = !!reportActions; const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); const [betas] = useOnyx(ONYXKEYS.BETAS); @@ -74,8 +75,8 @@ function ReportAttachmentModalContent({route, navigation}: AttachmentModalScreen return; } - openReport({reportID: reportActionReportID, introSelected, reportActionID, betas}); - }, [reportActionReportID, shouldFetchReport, introSelected, reportActionID, betas]); + openReport({reportID: reportActionReportID, introSelected, reportActionID, betas, isReportActionsExist}); + }, [reportActionReportID, shouldFetchReport, introSelected, reportActionID, betas, isReportActionsExist]); const onCarouselAttachmentChange = (attachment: Attachment) => { const routeToNavigate = ROUTES.REPORT_ATTACHMENTS.getRoute({ diff --git a/tests/actions/IOUTest/DeleteMoneyRequestTest.ts b/tests/actions/IOUTest/DeleteMoneyRequestTest.ts index 86661ad5afef..24aa69c6585e 100644 --- a/tests/actions/IOUTest/DeleteMoneyRequestTest.ts +++ b/tests/actions/IOUTest/DeleteMoneyRequestTest.ts @@ -536,6 +536,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { })); // When Opening a thread report with the given details openReport({ + isReportActionsExist: true, reportID: thread.reportID, introSelected: TEST_INTRO_SELECTED, betas: undefined, @@ -644,6 +645,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { // When Opening a thread report with the given details openReport({ + isReportActionsExist: true, reportID: thread.reportID, introSelected: TEST_INTRO_SELECTED, betas: undefined, @@ -776,6 +778,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { accountID: participantAccountIDs.at(index), })); openReport({ + isReportActionsExist: true, reportID: thread.reportID, introSelected: TEST_INTRO_SELECTED, betas: undefined, @@ -922,6 +925,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { accountID: participantAccountIDs.at(index), })); openReport({ + isReportActionsExist: true, reportID: thread.reportID, introSelected: TEST_INTRO_SELECTED, betas: undefined, @@ -1238,6 +1242,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { accountID: participantAccountIDs.at(index), })); openReport({ + isReportActionsExist: true, reportID: thread.reportID, introSelected: TEST_INTRO_SELECTED, betas: undefined, @@ -1419,6 +1424,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { accountID: participantAccountIDs.at(index), })); openReport({ + isReportActionsExist: true, reportID: thread.reportID, introSelected: TEST_INTRO_SELECTED, betas: undefined, diff --git a/tests/actions/IOUTest/DuplicateTest.ts b/tests/actions/IOUTest/DuplicateTest.ts index bd2a277a0b97..d200720871fe 100644 --- a/tests/actions/IOUTest/DuplicateTest.ts +++ b/tests/actions/IOUTest/DuplicateTest.ts @@ -462,6 +462,7 @@ describe('actions/Duplicate', () => { accountID: participantAccountIDs.at(index), })); openReport({ + isReportActionsExist: true, reportID: transactionThreadReport1.reportID, introSelected: undefined, personalDetails: allPersonalDetails, @@ -471,6 +472,7 @@ describe('actions/Duplicate', () => { parentReportActionID: iouAction1?.reportActionID, }); openReport({ + isReportActionsExist: true, reportID: transactionThreadReport2.reportID, introSelected: undefined, personalDetails: allPersonalDetails, diff --git a/tests/actions/IOUTest/TrackExpenseTest.ts b/tests/actions/IOUTest/TrackExpenseTest.ts index fbb7c58dfb5f..9c546109edab 100644 --- a/tests/actions/IOUTest/TrackExpenseTest.ts +++ b/tests/actions/IOUTest/TrackExpenseTest.ts @@ -2438,6 +2438,7 @@ describe('actions/IOU/TrackExpense', () => { accountID: participantAccountIDs.at(index), })); openReport({ + isReportActionsExist: true, reportID: thread.reportID, introSelected: TEST_INTRO_SELECTED, betas: undefined, @@ -2549,6 +2550,7 @@ describe('actions/IOU/TrackExpense', () => { accountID: participantAccountIDs.at(index), })); openReport({ + isReportActionsExist: true, reportID: thread.reportID, introSelected: TEST_INTRO_SELECTED, betas: undefined, diff --git a/tests/actions/MergeTransactionTest.ts b/tests/actions/MergeTransactionTest.ts index 49e53031354b..60d345fd1b4f 100644 --- a/tests/actions/MergeTransactionTest.ts +++ b/tests/actions/MergeTransactionTest.ts @@ -1145,6 +1145,7 @@ describe('mergeTransactionRequest', () => { accountID: participantAccountIDs.at(index), })); openReport({ + isReportActionsExist: true, reportID: thread.reportID, introSelected: undefined, participants, @@ -1329,6 +1330,7 @@ describe('mergeTransactionRequest', () => { accountID: participantAccountIDs.at(index), })); openReport({ + isReportActionsExist: true, reportID: thread.reportID, introSelected: undefined, participants, diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index 2ed6d5702cb0..7494127c90b0 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -615,7 +615,7 @@ describe('actions/Report', () => { // When the user visits the report currentTime = DateUtils.getDBTime(); - Report.openReport({reportID: REPORT_ID, introSelected: TEST_INTRO_SELECTED, betas: undefined}); + Report.openReport({isReportActionsExist: true, reportID: REPORT_ID, introSelected: TEST_INTRO_SELECTED, betas: undefined}); Report.readNewestAction(REPORT_ID, true); waitForBatchedUpdates(); return waitForBatchedUpdates(); @@ -1169,6 +1169,7 @@ describe('actions/Report', () => { for (let i = 0; i < 5; i++) { Report.openReport({ + isReportActionsExist: true, reportID: REPORT_ID, introSelected: TEST_INTRO_SELECTED, participants: [{login: 'test@user.com'}], @@ -1195,11 +1196,7 @@ describe('actions/Report', () => { setHasRadio(false); await waitForBatchedUpdates(); - Report.openReport({ - reportID: REPORT_ID, - introSelected: undefined, - betas: undefined, - }); + Report.openReport({isReportActionsExist: true, reportID: REPORT_ID, introSelected: undefined, betas: undefined}); await waitForBatchedUpdates(); const report = await getOnyxValue(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`); @@ -1216,6 +1213,7 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); Report.openReport({ + isReportActionsExist: true, reportID: REPORT_ID, introSelected: undefined, betas: undefined, @@ -1289,7 +1287,14 @@ describe('actions/Report', () => { const transaction = await getOnyxValue(`${ONYXKEYS.COLLECTION.TRANSACTION}${TXN_ID}` as const); expect(transaction).toBeTruthy(); - Report.openReport({reportID: CHILD_REPORT_ID, introSelected: undefined, betas: undefined, transaction: transaction ?? undefined, parentReportID: SELF_DM_ID}); + Report.openReport({ + isReportActionsExist: true, + reportID: CHILD_REPORT_ID, + introSelected: undefined, + betas: undefined, + transaction: transaction ?? undefined, + parentReportID: SELF_DM_ID, + }); await waitForBatchedUpdates(); // Validate the correct Onyx key received the new action and existing one is preserved @@ -1335,6 +1340,7 @@ describe('actions/Report', () => { reportID = `${i}`; } Report.openReport({ + isReportActionsExist: true, reportID, introSelected: TEST_INTRO_SELECTED, participants: [{login: 'test@user.com'}], @@ -2283,6 +2289,7 @@ describe('actions/Report', () => { const reportAction = TestHelper.buildTestReportComment(created, TEST_USER_ACCOUNT_ID, reportActionID); Report.openReport({ + isReportActionsExist: true, reportID: REPORT_ID, introSelected: TEST_INTRO_SELECTED, participants: [{login: 'test@user.com'}], @@ -4873,7 +4880,7 @@ describe('actions/Report', () => { await Onyx.set(ONYXKEYS.NVP_INTRO_SELECTED, TEST_INTRO_SELECTED); await waitForBatchedUpdates(); - Report.openReport({reportID: REPORT_ID, introSelected: TEST_INTRO_SELECTED, betas: undefined}); + Report.openReport({isReportActionsExist: true, reportID: REPORT_ID, introSelected: TEST_INTRO_SELECTED, betas: undefined}); await waitForBatchedUpdates(); TestHelper.expectAPICommandToHaveBeenCalled(WRITE_COMMANDS.OPEN_REPORT, 1); @@ -4884,7 +4891,7 @@ describe('actions/Report', () => { const REPORT_ID = '2'; - Report.openReport({reportID: REPORT_ID, introSelected: TEST_INTRO_SELECTED, betas: undefined}); + Report.openReport({isReportActionsExist: true, reportID: REPORT_ID, introSelected: TEST_INTRO_SELECTED, betas: undefined}); await waitForBatchedUpdates(); TestHelper.expectAPICommandToHaveBeenCalled(WRITE_COMMANDS.OPEN_REPORT, 1); @@ -4895,7 +4902,7 @@ describe('actions/Report', () => { const REPORT_ID = '3'; - Report.openReport({reportID: REPORT_ID, introSelected: undefined, betas: undefined}); + Report.openReport({isReportActionsExist: true, reportID: REPORT_ID, introSelected: undefined, betas: undefined}); await waitForBatchedUpdates(); TestHelper.expectAPICommandToHaveBeenCalled(WRITE_COMMANDS.OPEN_REPORT, 1); From 106f520c1827f148d2e9b3ed92448ddf17db3445 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 7 Jul 2026 15:17:08 +0800 Subject: [PATCH 2/4] remove todo --- src/libs/actions/Report/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts index 02bc812d16db..9679c089da57 100644 --- a/src/libs/actions/Report/index.ts +++ b/src/libs/actions/Report/index.ts @@ -361,7 +361,6 @@ type OpenReportActionParams = { hasCompletedGuidedSetupFlow?: boolean; /** Whether the report has report actions or not */ - // TODO: This will be required eventually. Refactor issue: https://github.com/Expensify/App/issues/73651 isReportActionsExist?: boolean; /** Beta features list */ From 68a326e5b4c572b50dcf87bc5369fa2c621e383a Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 9 Jul 2026 23:56:49 +0800 Subject: [PATCH 3/4] rename --- .../MoneyRequestReportActionsList.tsx | 2 +- src/hooks/useOneTransactionThreadReportID.tsx | 20 +++++++++++++++++++ src/hooks/useReportActionsScroll.ts | 2 +- src/libs/actions/Report/index.ts | 6 +++--- .../routes/TransactionReceiptModalContent.tsx | 4 ++-- .../ReportAddAttachmentModalContent/index.tsx | 6 +++--- .../report/ReportAttachmentModalContent.tsx | 6 +++--- .../actions/IOUTest/DeleteMoneyRequestTest.ts | 12 +++++------ tests/actions/IOUTest/DuplicateTest.ts | 4 ++-- tests/actions/IOUTest/TrackExpenseTest.ts | 4 ++-- tests/actions/MergeTransactionTest.ts | 4 ++-- tests/actions/ReportTest.ts | 20 +++++++++---------- 12 files changed, 55 insertions(+), 35 deletions(-) create mode 100644 src/hooks/useOneTransactionThreadReportID.tsx diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx index 8066fe65db7b..e5129125416e 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx @@ -619,7 +619,7 @@ function MoneyRequestReportActionsList({onLayout}: MoneyRequestReportListProps) setIsFloatingMessageCounterVisible(false); if (!hasNewestReportAction) { - openReport({reportID, introSelected, betas, isReportActionsExist: true}); + openReport({reportID, introSelected, betas, hasReportActions: true}); reportScrollManager.scrollToEnd(); return; } diff --git a/src/hooks/useOneTransactionThreadReportID.tsx b/src/hooks/useOneTransactionThreadReportID.tsx new file mode 100644 index 000000000000..b28b6ad9f199 --- /dev/null +++ b/src/hooks/useOneTransactionThreadReportID.tsx @@ -0,0 +1,20 @@ +import {getOneTransactionThreadReportID} from '@libs/ReportActionsUtils'; + +import ONYXKEYS from '@src/ONYXKEYS'; + +import useNetwork from './useNetwork'; +import useOnyx from './useOnyx'; + +function useOneTransactionThreadReportID(reportID: string | undefined) { + const {isOffline} = useNetwork(); + const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`); + const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.chatReportID}`); + const [oneTransactionThreadReportID] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, { + selector: (actions) => getOneTransactionThreadReportID(report, chatReport, actions, isOffline), + }); + console.log('useOneTransactionThreadReportID', reportID, report, chatReport, oneTransactionThreadReportID); + + return oneTransactionThreadReportID; +} + +export default useOneTransactionThreadReportID; diff --git a/src/hooks/useReportActionsScroll.ts b/src/hooks/useReportActionsScroll.ts index e286c632c542..324755e705fd 100644 --- a/src/hooks/useReportActionsScroll.ts +++ b/src/hooks/useReportActionsScroll.ts @@ -334,7 +334,7 @@ function useReportActionsScroll({ if (!Navigation.getReportRHPActiveRoute()) { Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportID, undefined, undefined, backTo)); } - openReport({reportID, introSelected, betas, isReportActionsExist: true}); + openReport({reportID, introSelected, betas, hasReportActions: true}); reportScrollManager.scrollToBottom(); return; } diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts index 9679c089da57..254d8827a586 100644 --- a/src/libs/actions/Report/index.ts +++ b/src/libs/actions/Report/index.ts @@ -361,7 +361,7 @@ type OpenReportActionParams = { hasCompletedGuidedSetupFlow?: boolean; /** Whether the report has report actions or not */ - isReportActionsExist?: boolean; + hasReportActions?: boolean; /** Beta features list */ betas: OnyxEntry; @@ -1485,7 +1485,7 @@ function openReport(params: OpenReportActionParams) { currentUserAccountID, isSelfTourViewed, hasCompletedGuidedSetupFlow, - isReportActionsExist, + hasReportActions, } = params; if (!reportID) { return; @@ -1496,7 +1496,7 @@ function openReport(params: OpenReportActionParams) { const participantAccountIDList = participants.map((p) => p.accountID).filter((id): id is number => id !== undefined); const existingReportName = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]?.reportName; const isCreatingNewReport = !isEmptyObject(newReportObject); - const optimisticReport: Partial> = (isReportActionsExist ?? reportActionsExist(reportID)) || !existingReportName ? {} : {reportName: existingReportName}; + const optimisticReport: Partial> = (hasReportActions ?? reportActionsExist(reportID)) || !existingReportName ? {} : {reportName: existingReportName}; const optimisticData: Array< OnyxUpdate< diff --git a/src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx b/src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx index 2417c836edfd..c12c3dfbaa8c 100644 --- a/src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx +++ b/src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx @@ -63,7 +63,7 @@ function TransactionReceiptModalContent({navigation, route}: AttachmentModalScre const expensifyIcons = useMemoizedLazyExpensifyIcons(['Camera', 'Download', 'Crop', 'Trashcan', 'Rotate', 'Close', 'Checkmark']); const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`); - const [isReportActionsExist] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {selector: Boolean}); + const [hasReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {selector: Boolean}); const allTransactions = useAllTransactions(); const transactionMain = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(transactionID)}`]; const [transactionDraft] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${getNonEmptyStringOnyxID(transactionID)}`); @@ -185,7 +185,7 @@ function TransactionReceiptModalContent({navigation, route}: AttachmentModalScre if ((!!report && !!transaction) || isDraftTransaction) { return; } - openReport({reportID, introSelected, betas, isReportActionsExist}); + openReport({reportID, introSelected, betas, hasReportActions}); // I'm disabling the warning, as it expects to use exhaustive deps, even though we want this useEffect to run only on the first render. // eslint-disable-next-line react-hooks/exhaustive-deps }, []); diff --git a/src/pages/media/AttachmentModalScreen/routes/report/ReportAddAttachmentModalContent/index.tsx b/src/pages/media/AttachmentModalScreen/routes/report/ReportAddAttachmentModalContent/index.tsx index 2c78c2ed3db2..6adf224dc33a 100644 --- a/src/pages/media/AttachmentModalScreen/routes/report/ReportAddAttachmentModalContent/index.tsx +++ b/src/pages/media/AttachmentModalScreen/routes/report/ReportAddAttachmentModalContent/index.tsx @@ -59,15 +59,15 @@ function ReportAddAttachmentModalContent({route, navigation}: AttachmentModalScr // Extract the reportActionID from the attachmentID (format: reportActionID_index) const reportActionID = useMemo(() => attachmentID?.split('_')?.[0], [attachmentID]); - const isReportActionsExist = !!reportActions; + const hasReportActions = !!reportActions; const shouldFetchReport = useMemo(() => { return isEmptyObject(reportActions?.[reportActionID ?? CONST.DEFAULT_NUMBER_ID]); }, [reportActions, reportActionID]); const fetchReport = useCallback(() => { - openReport({reportID, introSelected, reportActionID, betas, isReportActionsExist}); - }, [reportID, introSelected, reportActionID, betas, isReportActionsExist]); + openReport({reportID, introSelected, reportActionID, betas, hasReportActions}); + }, [reportID, introSelected, reportActionID, betas, hasReportActions]); // Close the modal if user loses write access (e.g., admin switches "Who can post" to Admins only) useEffect(() => { diff --git a/src/pages/media/AttachmentModalScreen/routes/report/ReportAttachmentModalContent.tsx b/src/pages/media/AttachmentModalScreen/routes/report/ReportAttachmentModalContent.tsx index b41ca407f42a..cad45c9d1480 100644 --- a/src/pages/media/AttachmentModalScreen/routes/report/ReportAttachmentModalContent.tsx +++ b/src/pages/media/AttachmentModalScreen/routes/report/ReportAttachmentModalContent.tsx @@ -45,7 +45,7 @@ function ReportAttachmentModalContent({route, navigation}: AttachmentModalScreen } = route.params; const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`); - const isReportActionsExist = !!reportActions; + const hasReportActions = !!reportActions; const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); const [betas] = useOnyx(ONYXKEYS.BETAS); @@ -75,8 +75,8 @@ function ReportAttachmentModalContent({route, navigation}: AttachmentModalScreen return; } - openReport({reportID: reportActionReportID, introSelected, reportActionID, betas, isReportActionsExist}); - }, [reportActionReportID, shouldFetchReport, introSelected, reportActionID, betas, isReportActionsExist]); + openReport({reportID: reportActionReportID, introSelected, reportActionID, betas, hasReportActions}); + }, [reportActionReportID, shouldFetchReport, introSelected, reportActionID, betas, hasReportActions]); const onCarouselAttachmentChange = (attachment: Attachment) => { const routeToNavigate = ROUTES.REPORT_ATTACHMENTS.getRoute({ diff --git a/tests/actions/IOUTest/DeleteMoneyRequestTest.ts b/tests/actions/IOUTest/DeleteMoneyRequestTest.ts index 24aa69c6585e..c0cc6cfc5d8c 100644 --- a/tests/actions/IOUTest/DeleteMoneyRequestTest.ts +++ b/tests/actions/IOUTest/DeleteMoneyRequestTest.ts @@ -536,7 +536,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { })); // When Opening a thread report with the given details openReport({ - isReportActionsExist: true, + hasReportActions: true, reportID: thread.reportID, introSelected: TEST_INTRO_SELECTED, betas: undefined, @@ -645,7 +645,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { // When Opening a thread report with the given details openReport({ - isReportActionsExist: true, + hasReportActions: true, reportID: thread.reportID, introSelected: TEST_INTRO_SELECTED, betas: undefined, @@ -778,7 +778,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { accountID: participantAccountIDs.at(index), })); openReport({ - isReportActionsExist: true, + hasReportActions: true, reportID: thread.reportID, introSelected: TEST_INTRO_SELECTED, betas: undefined, @@ -925,7 +925,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { accountID: participantAccountIDs.at(index), })); openReport({ - isReportActionsExist: true, + hasReportActions: true, reportID: thread.reportID, introSelected: TEST_INTRO_SELECTED, betas: undefined, @@ -1242,7 +1242,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { accountID: participantAccountIDs.at(index), })); openReport({ - isReportActionsExist: true, + hasReportActions: true, reportID: thread.reportID, introSelected: TEST_INTRO_SELECTED, betas: undefined, @@ -1424,7 +1424,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { accountID: participantAccountIDs.at(index), })); openReport({ - isReportActionsExist: true, + hasReportActions: true, reportID: thread.reportID, introSelected: TEST_INTRO_SELECTED, betas: undefined, diff --git a/tests/actions/IOUTest/DuplicateTest.ts b/tests/actions/IOUTest/DuplicateTest.ts index d200720871fe..cd4598314943 100644 --- a/tests/actions/IOUTest/DuplicateTest.ts +++ b/tests/actions/IOUTest/DuplicateTest.ts @@ -462,7 +462,7 @@ describe('actions/Duplicate', () => { accountID: participantAccountIDs.at(index), })); openReport({ - isReportActionsExist: true, + hasReportActions: true, reportID: transactionThreadReport1.reportID, introSelected: undefined, personalDetails: allPersonalDetails, @@ -472,7 +472,7 @@ describe('actions/Duplicate', () => { parentReportActionID: iouAction1?.reportActionID, }); openReport({ - isReportActionsExist: true, + hasReportActions: true, reportID: transactionThreadReport2.reportID, introSelected: undefined, personalDetails: allPersonalDetails, diff --git a/tests/actions/IOUTest/TrackExpenseTest.ts b/tests/actions/IOUTest/TrackExpenseTest.ts index 9c546109edab..c98e2796b425 100644 --- a/tests/actions/IOUTest/TrackExpenseTest.ts +++ b/tests/actions/IOUTest/TrackExpenseTest.ts @@ -2438,7 +2438,7 @@ describe('actions/IOU/TrackExpense', () => { accountID: participantAccountIDs.at(index), })); openReport({ - isReportActionsExist: true, + hasReportActions: true, reportID: thread.reportID, introSelected: TEST_INTRO_SELECTED, betas: undefined, @@ -2550,7 +2550,7 @@ describe('actions/IOU/TrackExpense', () => { accountID: participantAccountIDs.at(index), })); openReport({ - isReportActionsExist: true, + hasReportActions: true, reportID: thread.reportID, introSelected: TEST_INTRO_SELECTED, betas: undefined, diff --git a/tests/actions/MergeTransactionTest.ts b/tests/actions/MergeTransactionTest.ts index 60d345fd1b4f..e6bc58ab9c64 100644 --- a/tests/actions/MergeTransactionTest.ts +++ b/tests/actions/MergeTransactionTest.ts @@ -1145,7 +1145,7 @@ describe('mergeTransactionRequest', () => { accountID: participantAccountIDs.at(index), })); openReport({ - isReportActionsExist: true, + hasReportActions: true, reportID: thread.reportID, introSelected: undefined, participants, @@ -1330,7 +1330,7 @@ describe('mergeTransactionRequest', () => { accountID: participantAccountIDs.at(index), })); openReport({ - isReportActionsExist: true, + hasReportActions: true, reportID: thread.reportID, introSelected: undefined, participants, diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index 7494127c90b0..47e54b481797 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -615,7 +615,7 @@ describe('actions/Report', () => { // When the user visits the report currentTime = DateUtils.getDBTime(); - Report.openReport({isReportActionsExist: true, reportID: REPORT_ID, introSelected: TEST_INTRO_SELECTED, betas: undefined}); + Report.openReport({hasReportActions: true, reportID: REPORT_ID, introSelected: TEST_INTRO_SELECTED, betas: undefined}); Report.readNewestAction(REPORT_ID, true); waitForBatchedUpdates(); return waitForBatchedUpdates(); @@ -1169,7 +1169,7 @@ describe('actions/Report', () => { for (let i = 0; i < 5; i++) { Report.openReport({ - isReportActionsExist: true, + hasReportActions: true, reportID: REPORT_ID, introSelected: TEST_INTRO_SELECTED, participants: [{login: 'test@user.com'}], @@ -1196,7 +1196,7 @@ describe('actions/Report', () => { setHasRadio(false); await waitForBatchedUpdates(); - Report.openReport({isReportActionsExist: true, reportID: REPORT_ID, introSelected: undefined, betas: undefined}); + Report.openReport({hasReportActions: true, reportID: REPORT_ID, introSelected: undefined, betas: undefined}); await waitForBatchedUpdates(); const report = await getOnyxValue(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`); @@ -1213,7 +1213,7 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); Report.openReport({ - isReportActionsExist: true, + hasReportActions: true, reportID: REPORT_ID, introSelected: undefined, betas: undefined, @@ -1288,7 +1288,7 @@ describe('actions/Report', () => { expect(transaction).toBeTruthy(); Report.openReport({ - isReportActionsExist: true, + hasReportActions: true, reportID: CHILD_REPORT_ID, introSelected: undefined, betas: undefined, @@ -1340,7 +1340,7 @@ describe('actions/Report', () => { reportID = `${i}`; } Report.openReport({ - isReportActionsExist: true, + hasReportActions: true, reportID, introSelected: TEST_INTRO_SELECTED, participants: [{login: 'test@user.com'}], @@ -2289,7 +2289,7 @@ describe('actions/Report', () => { const reportAction = TestHelper.buildTestReportComment(created, TEST_USER_ACCOUNT_ID, reportActionID); Report.openReport({ - isReportActionsExist: true, + hasReportActions: true, reportID: REPORT_ID, introSelected: TEST_INTRO_SELECTED, participants: [{login: 'test@user.com'}], @@ -4880,7 +4880,7 @@ describe('actions/Report', () => { await Onyx.set(ONYXKEYS.NVP_INTRO_SELECTED, TEST_INTRO_SELECTED); await waitForBatchedUpdates(); - Report.openReport({isReportActionsExist: true, reportID: REPORT_ID, introSelected: TEST_INTRO_SELECTED, betas: undefined}); + Report.openReport({hasReportActions: true, reportID: REPORT_ID, introSelected: TEST_INTRO_SELECTED, betas: undefined}); await waitForBatchedUpdates(); TestHelper.expectAPICommandToHaveBeenCalled(WRITE_COMMANDS.OPEN_REPORT, 1); @@ -4891,7 +4891,7 @@ describe('actions/Report', () => { const REPORT_ID = '2'; - Report.openReport({isReportActionsExist: true, reportID: REPORT_ID, introSelected: TEST_INTRO_SELECTED, betas: undefined}); + Report.openReport({hasReportActions: true, reportID: REPORT_ID, introSelected: TEST_INTRO_SELECTED, betas: undefined}); await waitForBatchedUpdates(); TestHelper.expectAPICommandToHaveBeenCalled(WRITE_COMMANDS.OPEN_REPORT, 1); @@ -4902,7 +4902,7 @@ describe('actions/Report', () => { const REPORT_ID = '3'; - Report.openReport({isReportActionsExist: true, reportID: REPORT_ID, introSelected: undefined, betas: undefined}); + Report.openReport({hasReportActions: true, reportID: REPORT_ID, introSelected: undefined, betas: undefined}); await waitForBatchedUpdates(); TestHelper.expectAPICommandToHaveBeenCalled(WRITE_COMMANDS.OPEN_REPORT, 1); From f2e2d50fcabaad51ac0826b8ebaca68b790631eb Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 10 Jul 2026 04:56:29 +0800 Subject: [PATCH 4/4] delete wrong commited file --- src/hooks/useOneTransactionThreadReportID.tsx | 20 ------------------- 1 file changed, 20 deletions(-) delete mode 100644 src/hooks/useOneTransactionThreadReportID.tsx diff --git a/src/hooks/useOneTransactionThreadReportID.tsx b/src/hooks/useOneTransactionThreadReportID.tsx deleted file mode 100644 index b28b6ad9f199..000000000000 --- a/src/hooks/useOneTransactionThreadReportID.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import {getOneTransactionThreadReportID} from '@libs/ReportActionsUtils'; - -import ONYXKEYS from '@src/ONYXKEYS'; - -import useNetwork from './useNetwork'; -import useOnyx from './useOnyx'; - -function useOneTransactionThreadReportID(reportID: string | undefined) { - const {isOffline} = useNetwork(); - const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`); - const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.chatReportID}`); - const [oneTransactionThreadReportID] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, { - selector: (actions) => getOneTransactionThreadReportID(report, chatReport, actions, isOffline), - }); - console.log('useOneTransactionThreadReportID', reportID, report, chatReport, oneTransactionThreadReportID); - - return oneTransactionThreadReportID; -} - -export default useOneTransactionThreadReportID;