From bb905f0a9a5328c115a403c7b654e8e1b1e40cfa Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Thu, 26 Mar 2026 18:10:21 +0530 Subject: [PATCH 1/2] Resolve admins room for task report --- src/pages/ScheduleCall/ScheduleCallPage.tsx | 24 +++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/pages/ScheduleCall/ScheduleCallPage.tsx b/src/pages/ScheduleCall/ScheduleCallPage.tsx index 1fa4bd71c973..32401face552 100644 --- a/src/pages/ScheduleCall/ScheduleCallPage.tsx +++ b/src/pages/ScheduleCall/ScheduleCallPage.tsx @@ -24,6 +24,7 @@ import {getLatestError} from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types'; import type {ScheduleCallParamList} from '@libs/Navigation/types'; +import {isAdminRoom, isTaskReport} from '@libs/ReportUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -55,17 +56,28 @@ function ScheduleCallPage() { const [scheduleCallDraft] = useOnyx(`${ONYXKEYS.SCHEDULE_CALL_DRAFT}`); const reportID = route.params?.reportID; - const [adminReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, { + const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`); + const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`); + const adminsRoomReportID = useMemo(() => { + // Task reports in #admins room have chatType as policyAdmins + // So for task report, we need to send the real #admins room i.e. the parent report. + if (isTaskReport(report) && parentReport?.reportID && isAdminRoom(parentReport)) { + return parentReport.reportID; + } + return reportID; + }, [report, parentReport, reportID]); + + const [adminReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${adminsRoomReportID}`, { selector: adminReportNameValuePairsSelector, }); const calendlySchedule = adminReportNameValuePairs?.calendlySchedule; useEffect(() => { - if (!reportID) { + if (!adminsRoomReportID) { return; } - getGuideCallAvailabilitySchedule(reportID); - }, [reportID]); + getGuideCallAvailabilitySchedule(adminsRoomReportID); + }, [adminsRoomReportID]); // Clear selected time when user comes back to the selection screen useFocusEffect( @@ -76,7 +88,7 @@ function ScheduleCallPage() { useEffect(() => { return () => { - sendScheduleCallNudge(session?.accountID ?? CONST.DEFAULT_NUMBER_ID, reportID); + sendScheduleCallNudge(session?.accountID ?? CONST.DEFAULT_NUMBER_ID, adminsRoomReportID); }; // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -224,7 +236,7 @@ function ScheduleCallPage() { accountID: timeSlot.guideAccountID, email: timeSlot.guideEmail, }, - reportID, + reportID: adminsRoomReportID, }); Navigation.navigate(ROUTES.SCHEDULE_CALL_CONFIRMATION.getRoute(reportID)); }} From 32002b2729c482c1a1a17e5d47347c79816a358f Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Thu, 26 Mar 2026 18:36:14 +0530 Subject: [PATCH 2/2] Remove useMemo --- src/pages/ScheduleCall/ScheduleCallPage.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/pages/ScheduleCall/ScheduleCallPage.tsx b/src/pages/ScheduleCall/ScheduleCallPage.tsx index 32401face552..02c31e54692c 100644 --- a/src/pages/ScheduleCall/ScheduleCallPage.tsx +++ b/src/pages/ScheduleCall/ScheduleCallPage.tsx @@ -58,14 +58,10 @@ function ScheduleCallPage() { const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`); const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`); - const adminsRoomReportID = useMemo(() => { - // Task reports in #admins room have chatType as policyAdmins - // So for task report, we need to send the real #admins room i.e. the parent report. - if (isTaskReport(report) && parentReport?.reportID && isAdminRoom(parentReport)) { - return parentReport.reportID; - } - return reportID; - }, [report, parentReport, reportID]); + + // Task reports in #admins room have chatType as policyAdmins, + // So for a task report, we need to send the real #admins room i.e., the parent report. + const adminsRoomReportID = isTaskReport(report) && parentReport?.reportID && isAdminRoom(parentReport) ? parentReport.reportID : reportID; const [adminReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${adminsRoomReportID}`, { selector: adminReportNameValuePairsSelector,