@@ -7650,6 +7650,85 @@ describe('actions/Report', () => {
76507650 } ) ;
76517651 } ) ;
76527652
7653+ it ( 'should fall back to ancestor report via parentReportID when parentReport matches current report' , async ( ) => {
7654+ global . fetch = TestHelper . getGlobalFetchMock ( ) ;
7655+
7656+ const TRANSACTION_THREAD_ID = '20' ;
7657+ const ANCESTOR_IOU_REPORT_ID = '21' ;
7658+ const WHISPER_ACTION_ID = '20001' ;
7659+ const EXISTING_PARTICIPANT_ID = 100 ;
7660+ const INVITEE_ACCOUNT_ID = 200 ;
7661+
7662+ // Transaction thread report — parentReportID points to the IOU ancestor
7663+ const transactionThreadReport : OnyxTypes . Report = {
7664+ ...createRandomReport ( 20 , undefined ) ,
7665+ reportID : TRANSACTION_THREAD_ID ,
7666+ parentReportID : ANCESTOR_IOU_REPORT_ID ,
7667+ participants : {
7668+ [ EXISTING_PARTICIPANT_ID ] : {
7669+ notificationPreference : CONST . REPORT . NOTIFICATION_PREFERENCE . ALWAYS ,
7670+ role : CONST . REPORT . ROLE . ADMIN ,
7671+ } ,
7672+ } ,
7673+ lastMessageText : 'Receipt' ,
7674+ lastVisibleActionCreated : '2024-11-19 08:04:13.728' ,
7675+ lastActorAccountID : EXISTING_PARTICIPANT_ID ,
7676+ } ;
7677+
7678+ // Ancestor IOU report (money request report)
7679+ const ancestorIOUReport : OnyxTypes . Report = {
7680+ ...createRandomReport ( 21 , undefined ) ,
7681+ reportID : ANCESTOR_IOU_REPORT_ID ,
7682+ type : CONST . REPORT . TYPE . IOU ,
7683+ participants : {
7684+ [ EXISTING_PARTICIPANT_ID ] : {
7685+ notificationPreference : CONST . REPORT . NOTIFICATION_PREFERENCE . ALWAYS ,
7686+ role : CONST . REPORT . ROLE . ADMIN ,
7687+ } ,
7688+ } ,
7689+ } ;
7690+
7691+ const whisperAction = {
7692+ reportActionID : WHISPER_ACTION_ID ,
7693+ reportID : TRANSACTION_THREAD_ID ,
7694+ actionName : CONST . REPORT . ACTIONS . TYPE . ACTIONABLE_MENTION_WHISPER ,
7695+ created : '2024-11-19 08:04:13.730' ,
7696+ message : [ { html : 'Mentioned @user1' , text : 'Mentioned @user1' , type : 'COMMENT' } ] ,
7697+ originalMessage : {
7698+ inviteeAccountIDs : [ INVITEE_ACCOUNT_ID ] ,
7699+ inviteeEmails : [ 'user1@example.com' ] ,
7700+ whisperedTo : [ EXISTING_PARTICIPANT_ID ] ,
7701+ } ,
7702+ } as unknown as OnyxTypes . ReportAction ;
7703+
7704+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ TRANSACTION_THREAD_ID } ` , transactionThreadReport ) ;
7705+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ ANCESTOR_IOU_REPORT_ID } ` , ancestorIOUReport ) ;
7706+ await Onyx . mergeCollection ( ONYXKEYS . COLLECTION . REPORT_ACTIONS , {
7707+ [ `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ TRANSACTION_THREAD_ID } ` ] : {
7708+ [ WHISPER_ACTION_ID ] : whisperAction ,
7709+ } ,
7710+ } ) ;
7711+ await waitForBatchedUpdates ( ) ;
7712+
7713+ // Pass parentReport as the same report (simulating viewing transaction thread directly)
7714+ Report . resolveActionableMentionWhisper ( transactionThreadReport , whisperAction , CONST . REPORT . ACTIONABLE_MENTION_WHISPER_RESOLUTION . INVITE , false , transactionThreadReport ) ;
7715+ await waitForBatchedUpdates ( ) ;
7716+
7717+ // Verify the invitee was added to the transaction thread participants
7718+ const updatedThreadReport = await getOnyxValue ( `${ ONYXKEYS . COLLECTION . REPORT } ${ TRANSACTION_THREAD_ID } ` as const ) ;
7719+ expect ( updatedThreadReport ?. participants ?. [ INVITEE_ACCOUNT_ID ] ) . toMatchObject ( {
7720+ notificationPreference : CONST . REPORT . NOTIFICATION_PREFERENCE . ALWAYS ,
7721+ role : CONST . REPORT . ROLE . MEMBER ,
7722+ } ) ;
7723+
7724+ // Verify the invitee was also added to the ancestor IOU report via the fallback path
7725+ const updatedAncestorReport = await getOnyxValue ( `${ ONYXKEYS . COLLECTION . REPORT } ${ ANCESTOR_IOU_REPORT_ID } ` as const ) ;
7726+ expect ( updatedAncestorReport ?. participants ?. [ INVITEE_ACCOUNT_ID ] ) . toMatchObject ( {
7727+ notificationPreference : CONST . REPORT . NOTIFICATION_PREFERENCE . ALWAYS ,
7728+ role : CONST . REPORT . ROLE . MEMBER ,
7729+ } ) ;
7730+ } ) ;
7731+
76537732 it ( 'should remove optimistically added participants on failure rollback' , async ( ) => {
76547733 const mockFetch = TestHelper . getGlobalFetchMock ( ) as MockFetch ;
76557734 global . fetch = mockFetch ;
0 commit comments