diff --git a/src/CONST.ts b/src/CONST.ts index 9dabe944620f..789e9b588609 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -926,6 +926,7 @@ const CONST = { ADMIN_TOUR_STAGING: 'https://expensify.navattic.com/3i300k18', EMPLOYEE_TOUR_PRODUCTION: 'https://expensify.navattic.com/35609gb', EMPLOYEE_TOUR_STAGING: 'https://expensify.navattic.com/cf15002s', + COMPLETED: 'completed', }, OLD_DOT_PUBLIC_URLS: { TERMS_URL: `${EXPENSIFY_URL}/terms`, diff --git a/src/pages/ConciergePage.tsx b/src/pages/ConciergePage.tsx index 40e2a6094ac7..0ce089787230 100644 --- a/src/pages/ConciergePage.tsx +++ b/src/pages/ConciergePage.tsx @@ -1,4 +1,4 @@ -import {useFocusEffect} from '@react-navigation/native'; +import {useFocusEffect, useRoute} from '@react-navigation/native'; import React, {useCallback, useEffect, useRef} from 'react'; import {View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; @@ -10,6 +10,8 @@ import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; import * as App from '@userActions/App'; import * as Report from '@userActions/Report'; +import * as Task from '@userActions/Task'; +import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; /* @@ -23,6 +25,11 @@ function ConciergePage() { const {shouldUseNarrowLayout} = useResponsiveLayout(); const [session] = useOnyx(ONYXKEYS.SESSION); const [isLoadingReportData] = useOnyx(ONYXKEYS.IS_LOADING_REPORT_DATA, {initialValue: true}); + const route = useRoute(); + + const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); + const viewTourTaskReportID = introSelected?.viewTour; + const [viewTourTaskReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${viewTourTaskReportID}`); useFocusEffect( useCallback(() => { @@ -32,12 +39,22 @@ function ConciergePage() { if (isUnmounted.current || isLoadingReportData === undefined || !!isLoadingReportData) { return; } + + // Mark the viewTourTask as complete if we are redirected to Concierge after finishing the Navattic tour + const {navattic} = route.params as {navattic?: string}; + if (navattic === CONST.NAVATTIC.COMPLETED) { + if (viewTourTaskReport) { + if (viewTourTaskReport.stateNum !== CONST.REPORT.STATE_NUM.APPROVED || viewTourTaskReport.statusNum !== CONST.REPORT.STATUS_NUM.APPROVED) { + Task.completeTask(viewTourTaskReport); + } + } + } Report.navigateToConciergeChat(true, () => !isUnmounted.current); }); } else { Navigation.navigate(); } - }, [session, isLoadingReportData]), + }, [session, isLoadingReportData, route.params, viewTourTaskReport]), ); useEffect(() => {