1- import type { Report , ReportAction } from '@src/types/onyx' ;
1+ import Onyx from 'react-native-onyx' ;
2+ import type { OnyxCollection } from 'react-native-onyx' ;
3+ import ONYXKEYS from '@src/ONYXKEYS' ;
4+ import type { Policy , PolicyTagLists , Report , ReportAction } from '@src/types/onyx' ;
25import BrowserNotifications from './BrowserNotifications' ;
36import type { LocalNotificationClickHandler , LocalNotificationModifiedExpenseParams , LocalNotificationModule } from './types' ;
47
8+ let allPolicies : OnyxCollection < Policy > ;
9+ // This is a temporary subscription until the modified-expense notification chain is fully migrated
10+ // see https://github.com/Expensify/App/issues/66336
11+ Onyx . connectWithoutView ( {
12+ key : ONYXKEYS . COLLECTION . POLICY ,
13+ waitForCollectionCallback : true ,
14+ callback : ( value ) => {
15+ allPolicies = value ;
16+ } ,
17+ } ) ;
18+
19+ let allPolicyTags : OnyxCollection < PolicyTagLists > ;
20+ // This is a temporary subscription until the modified-expense notification chain is fully migrated
21+ // see https://github.com/Expensify/App/issues/66336
22+ Onyx . connectWithoutView ( {
23+ key : ONYXKEYS . COLLECTION . POLICY_TAGS ,
24+ waitForCollectionCallback : true ,
25+ callback : ( value ) => {
26+ allPolicyTags = value ;
27+ } ,
28+ } ) ;
29+
530function showCommentNotification ( report : Report , reportAction : ReportAction , onClick : LocalNotificationClickHandler , conciergeReportID : string | undefined ) {
631 BrowserNotifications . pushReportCommentNotification ( report , reportAction , onClick , conciergeReportID , true ) ;
732}
@@ -10,8 +35,11 @@ function showUpdateAvailableNotification() {
1035 BrowserNotifications . pushUpdateAvailableNotification ( ) ;
1136}
1237
13- function showModifiedExpenseNotification ( { report, reportAction, movedFromReport, movedToReport, currentUserLogin, onClick} : LocalNotificationModifiedExpenseParams ) {
14- BrowserNotifications . pushModifiedExpenseNotification ( { report, reportAction, movedFromReport, movedToReport, onClick, usesIcon : true , currentUserLogin} ) ;
38+ function showModifiedExpenseNotification ( { report, reportAction, movedFromReport, movedToReport, onClick, currentUserLogin} : LocalNotificationModifiedExpenseParams ) {
39+ const policyID = report . policyID ;
40+ const policyTags = policyID ? allPolicyTags ?. [ `${ ONYXKEYS . COLLECTION . POLICY_TAGS } ${ policyID } ` ] : undefined ;
41+ const policy = policyID ? allPolicies ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ policyID } ` ] : undefined ;
42+ BrowserNotifications . pushModifiedExpenseNotification ( { report, reportAction, movedFromReport, movedToReport, onClick, usesIcon : true , policyTags, policy, currentUserLogin} ) ;
1543}
1644
1745function clearReportNotifications ( reportID : string | undefined ) {
0 commit comments