@@ -31,10 +31,11 @@ import {
3131} from '@libs/ReportUtils' ;
3232
3333import CONST from '@src/CONST' ;
34- import { isDistanceRequest , isTransactionPendingDelete } from '@src/libs/TransactionUtils' ;
34+ import { getReportOwnerAccountIDAsAttendee , getReportOwnerAsAttendee , isDistanceRequest , isTransactionPendingDelete } from '@src/libs/TransactionUtils' ;
3535import ONYXKEYS from '@src/ONYXKEYS' ;
3636import { DYNAMIC_ROUTES } from '@src/ROUTES' ;
37- import type { CardList , MergeTransaction , Policy , PolicyCategories , PolicyTagLists , Report , ReportActions , Transaction , TransactionViolations } from '@src/types/onyx' ;
37+ import type { CardList , MergeTransaction , PersonalDetailsList , Policy , PolicyCategories , PolicyTagLists , Report , ReportActions , Transaction , TransactionViolations } from '@src/types/onyx' ;
38+ import type { Attendee } from '@src/types/onyx/IOU' ;
3839
3940import type { OnyxCollection , OnyxEntry , OnyxMergeInput , OnyxUpdate } from 'react-native-onyx' ;
4041
@@ -47,6 +48,20 @@ import {getCleanUpTransactionThreadReportOnyxData} from './IOU/DeleteMoneyReques
4748import { getDeleteTrackExpenseInformation } from './IOU/TrackExpense' ;
4849import { getUpdateMoneyRequestParams , getUpdateTrackExpenseParams } from './IOU/UpdateMoneyRequest' ;
4950
51+ /**
52+ * Resolve a transaction's report owner as a default attendee, mirroring the `useReportOwnerAsAttendee` hook so the
53+ * non-React merge entry point can apply the same empty-attendee fallback the details/receipt pages use. The Onyx data
54+ * is passed in by the caller rather than read from a module subscription.
55+ */
56+ function getReportOwnerAsAttendeeForTransaction (
57+ transaction : OnyxEntry < Transaction > ,
58+ currentUserAccountID : number | undefined ,
59+ personalDetails : OnyxEntry < PersonalDetailsList > ,
60+ ) : Attendee | undefined {
61+ const ownerAccountID = getReportOwnerAccountIDAsAttendee ( transaction , currentUserAccountID ) ;
62+ return getReportOwnerAsAttendee ( ownerAccountID ? ( personalDetails ?. [ ownerAccountID ] ?? undefined ) : undefined ) ;
63+ }
64+
5065/**
5166 * Setup merge transaction data for merging flow
5267 */
@@ -91,6 +106,8 @@ function setupMergeTransactionDataAndNavigate(
91106 isSelectingSourceTransaction ?: boolean ,
92107 isOnSearch ?: boolean ,
93108 policies ?: Array < OnyxEntry < Policy > > ,
109+ currentUserAccountID ?: number ,
110+ personalDetails ?: OnyxEntry < PersonalDetailsList > ,
94111) {
95112 if ( ! transactions . length || transactions . length > 2 ) {
96113 return ;
@@ -139,6 +156,8 @@ function setupMergeTransactionDataAndNavigate(
139156 searchReports ,
140157 targetTransactionPolicy ,
141158 sourceTransactionPolicy ,
159+ getReportOwnerAsAttendeeForTransaction ( targetTransaction , currentUserAccountID , personalDetails ) ,
160+ getReportOwnerAsAttendeeForTransaction ( sourceTransaction , currentUserAccountID , personalDetails ) ,
142161 ) ;
143162 if ( ! conflictFields . length ) {
144163 // If there are no conflict fields, we should set mergeable data and navigate to the confirmation page
0 commit comments