@@ -18,7 +18,7 @@ import {toLocaleDigit} from '@libs/LocaleDigitUtils';
1818import { translateLocal } from '@libs/Localize' ;
1919import Log from '@libs/Log' ;
2020import { rand64 , roundToTwoDecimalPlaces } from '@libs/NumberUtils' ;
21- import { getPersonalDetailByEmail } from '@libs/PersonalDetailsUtils' ;
21+ import { getPersonalDetailsByIDs } from '@libs/PersonalDetailsUtils' ;
2222import {
2323 getCommaSeparatedTagNameWithSanitizedColons ,
2424 getDistanceRateCustomUnitRate ,
@@ -731,18 +731,29 @@ function getMerchantOrDescription(transaction: OnyxEntry<Transaction>) {
731731 */
732732function getAttendees ( transaction : OnyxInputOrEntry < Transaction > ) : Attendee [ ] {
733733 const attendees = transaction ?. modifiedAttendees ? transaction . modifiedAttendees : ( transaction ?. comment ?. attendees ?? [ ] ) ;
734- if ( attendees . length === 0 ) {
735- const details = getPersonalDetailByEmail ( currentUserEmail ) ;
736- attendees . push ( {
737- email : currentUserEmail ,
738- login : details ?. login ?? currentUserEmail ,
739- displayName : details ?. displayName ?? currentUserEmail ,
740- accountID : currentUserAccountID ,
741- text : details ?. displayName ?? currentUserEmail ,
742- searchText : details ?. displayName ?? currentUserEmail ,
743- avatarUrl : details ?. avatarThumbnail ?? '' ,
744- selected : true ,
745- } ) ;
734+ if ( attendees . length === 0 && transaction ?. reportID ) {
735+ // Get the creator of the transaction by looking at the owner of the report linked to the transaction
736+ const report = getReportOrDraftReport ( transaction . reportID ) ;
737+ const creatorAccountID = report ?. ownerAccountID ;
738+
739+ if ( creatorAccountID ) {
740+ const [ creatorDetails ] = getPersonalDetailsByIDs ( { accountIDs : [ creatorAccountID ] , currentUserAccountID} ) ;
741+ const creatorEmail = creatorDetails ?. login ?? '' ;
742+ const creatorDisplayName = creatorDetails ?. displayName ?? creatorEmail ;
743+
744+ if ( creatorEmail ) {
745+ attendees . push ( {
746+ email : creatorEmail ,
747+ login : creatorEmail ,
748+ displayName : creatorDisplayName ,
749+ accountID : creatorAccountID ,
750+ text : creatorDisplayName ,
751+ searchText : creatorDisplayName ,
752+ avatarUrl : creatorDetails ?. avatarThumbnail ?? '' ,
753+ selected : true ,
754+ } ) ;
755+ }
756+ }
746757 }
747758 return attendees ;
748759}
0 commit comments