diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 0ea325cacf00..1ed54c826e40 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -17,7 +17,6 @@ import * as Environment from '@libs/Environment/Environment'; import * as ErrorUtils from '@libs/ErrorUtils'; import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; -import clearReportNotifications from '@libs/Notification/clearReportNotifications'; import LocalNotification from '@libs/Notification/LocalNotification'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; @@ -477,8 +476,6 @@ function openReport( return; } - clearReportNotifications(reportID); - const optimisticReport = reportActionsExist(reportID) ? {} : { diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 1974296c82e1..6afe7f92075b 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -299,17 +299,17 @@ function ReportScreen({ [route], ); - // Clear notifications for the current report when the app is focused - useAppFocusEvent( - useCallback(() => { - // Check if this is the top-most ReportScreen since the Navigator preserves multiple at a time - if (!isTopMostReportId) { - return; - } + // Clear notifications for the current report when it's opened and re-focused + const clearNotifications = useCallback(() => { + // Check if this is the top-most ReportScreen since the Navigator preserves multiple at a time + if (!isTopMostReportId) { + return; + } - clearReportNotifications(report.reportID); - }, [report.reportID, isTopMostReportId]), - ); + clearReportNotifications(report.reportID); + }, [report.reportID, isTopMostReportId]); + useEffect(clearNotifications, [clearNotifications]); + useAppFocusEvent(clearNotifications); useEffect(() => { Timing.end(CONST.TIMING.CHAT_RENDER);