@@ -185,6 +185,7 @@ import {
185185 isPending ,
186186 isScanning ,
187187 isViolationDismissed ,
188+ shouldShowAttendees as shouldShowAttendeesUtils ,
188189 shouldShowViolation ,
189190} from './TransactionUtils' ;
190191import { isInvalidMerchantValue } from './ValidationUtils' ;
@@ -243,6 +244,7 @@ type GetTransactionSectionsParams = {
243244 reportActions ?: Record < string , OnyxTypes . ReportAction [ ] > ;
244245 queryJSON ?: SearchQueryJSON ;
245246 cardFeeds ?: OnyxCollection < OnyxTypes . CardFeeds > ;
247+ policyForMovingExpenses ?: OnyxTypes . Policy ;
246248} ;
247249
248250const transactionColumnNamesToSortingProperty : TransactionSorting = {
@@ -545,6 +547,7 @@ type GetSectionsParams = {
545547 allReportMetadata : OnyxCollection < OnyxTypes . ReportMetadata > ;
546548 conciergeReportID : string | undefined ;
547549 onyxPersonalDetailsList ?: OnyxTypes . PersonalDetailsList ;
550+ policyForMovingExpenses ?: OnyxTypes . Policy ;
548551} ;
549552
550553/**
@@ -2008,6 +2011,7 @@ function getTransactionsSections({
20082011 reportActions = { } ,
20092012 queryJSON,
20102013 cardFeeds,
2014+ policyForMovingExpenses,
20112015} : GetTransactionSectionsParams ) : [ TransactionListItemType [ ] , number ] {
20122016 const {
20132017 transactionKeys,
@@ -2026,6 +2030,7 @@ function getTransactionsSections({
20262030 } = classifyAndPreprocess ( data ) ;
20272031
20282032 const personalDetailsMap = new Map ( Object . entries ( data . personalDetailsList ?? { } ) ) ;
2033+ const currentUserPersonalDetails = personalDetailsMap . get ( currentAccountID . toString ( ) ) ?? emptyPersonalDetails ;
20292034
20302035 const transactionsSections : TransactionListItemType [ ] = [ ] ;
20312036
@@ -2080,9 +2085,17 @@ function getTransactionsSections({
20802085 const reportMetadata = allReportMetadata ?. [ `${ ONYXKEYS . COLLECTION . REPORT_METADATA } ${ transactionItem . reportID } ` ] ?? { } ;
20812086 const allActions = getActions ( data , allViolations , key , currentSearch , currentUserEmail , currentAccountID , bankAccountList , reportMetadata , actions ) ;
20822087 const transactionPendingAction = getTransactionPendingAction ( transactionItem ) ;
2088+ const transactionAttendees = getAttendees ( transactionItem , currentUserPersonalDetails ) ;
2089+ const isUnReported = transactionItem . reportID === CONST . REPORT . UNREPORTED_REPORT_ID ;
2090+ const shouldShowAttendees = shouldShowAttendeesUtils ( CONST . IOU . TYPE . SUBMIT , isUnReported ? policyForMovingExpenses : policy ) && transactionAttendees . length > 0 ;
2091+
20832092 const transactionSection : TransactionListItemType = {
20842093 ...transactionItem ,
20852094 ...( transactionPendingAction ? { pendingAction : transactionPendingAction } : { } ) ,
2095+ comment : {
2096+ ...transactionItem . comment ,
2097+ attendees : shouldShowAttendees ? transactionAttendees : [ ] ,
2098+ } ,
20862099 keyForList : transactionItem . transactionID ,
20872100 action : getAction ( allActions ) ,
20882101 allActions,
@@ -3353,6 +3366,7 @@ function getSections({
33533366 allReportMetadata,
33543367 conciergeReportID,
33553368 onyxPersonalDetailsList,
3369+ policyForMovingExpenses,
33563370} : GetSectionsParams ) {
33573371 if ( type === CONST . SEARCH . DATA_TYPES . CHAT ) {
33583372 return getReportActionsSections ( data , visibleReportActionsData ) ;
@@ -3420,6 +3434,7 @@ function getSections({
34203434 reportActions,
34213435 queryJSON,
34223436 cardFeeds,
3437+ policyForMovingExpenses,
34233438 } ) ;
34243439}
34253440
@@ -3659,15 +3674,15 @@ function getSortedTransactionData(
36593674
36603675 if ( sortBy === CONST . SEARCH . TABLE_COLUMNS . ATTENDEES ) {
36613676 return data . sort ( ( a , b ) => {
3662- const aValue = getAttendees ( a , undefined ) . length ;
3663- const bValue = getAttendees ( b , undefined ) . length ;
3677+ const aValue = a . comment ?. attendees ?. length ?? 0 ;
3678+ const bValue = b . comment ?. attendees ?. length ?? 0 ;
36643679 return compareValues ( aValue , bValue , sortOrder , sortBy , localeCompare ) ;
36653680 } ) ;
36663681 }
36673682
36683683 if ( sortBy === CONST . SEARCH . TABLE_COLUMNS . TOTAL_PER_ATTENDEE ) {
36693684 const getTotalPerAttendee = ( t : TransactionListItemType ) => {
3670- const attendeesCount = getAttendees ( t , undefined ) . length ;
3685+ const attendeesCount = t . comment ?. attendees ?. length ?? 0 ;
36713686 if ( ! attendeesCount ) {
36723687 return 0 ;
36733688 }
0 commit comments