diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 1de0497dcf21..421a305b6c2f 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -487,8 +487,9 @@ function addActions(reportID: string, text = '', file?: FileObject) { }; const report = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; + const shouldUpdateNotificationPrefernece = !isEmptyObject(report) && ReportUtils.getReportNotificationPreference(report) === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; - if (!isEmptyObject(report) && ReportUtils.getReportNotificationPreference(report) === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) { + if (shouldUpdateNotificationPrefernece) { optimisticReport.notificationPreference = CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS; } @@ -543,6 +544,17 @@ function addActions(reportID: string, text = '', file?: FileObject) { }, ]; + if (shouldUpdateNotificationPrefernece) { + // optimisticReport.notificationPreference = CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS; + successData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + value: { + notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, + }, + }); + } + let failureReport: Partial = { lastMessageTranslationKey: '', lastMessageText: '',