@@ -16,16 +16,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
1616import ControlSelection from '@libs/ControlSelection' ;
1717import DateUtils from '@libs/DateUtils' ;
1818import Navigation from '@libs/Navigation/Navigation' ;
19- import { getPersonalDetailByEmail } from '@libs/PersonalDetailsUtils' ;
20- import {
21- getDelegateAccountIDFromReportAction ,
22- getHumanAgentAccountIDFromReportAction ,
23- getManagerOnVacation ,
24- getModerationFlagState ,
25- getOriginalMessage ,
26- getSubmittedTo ,
27- getVacationer ,
28- } from '@libs/ReportActionsUtils' ;
19+ import { getDelegateAccountIDFromReportAction , getHumanAgentAccountIDFromReportAction , getManagerOnVacation , getModerationFlagState , getVacationer } from '@libs/ReportActionsUtils' ;
2920import { isOptimisticPersonalDetail } from '@libs/ReportUtils' ;
3021import CONST from '@src/CONST' ;
3122import ROUTES from '@src/ROUTES' ;
@@ -35,6 +26,7 @@ import DelegateOnBehalfOfText from './DelegateOnBehalfOfText';
3526import HumanAgentAssistedByText from './HumanAgentAssistedByText' ;
3627import ReportActionItemDate from './ReportActionItemDate' ;
3728import ReportActionItemFragment from './ReportActionItemFragment' ;
29+ import VacationDelegateText from './VacationDelegateText' ;
3830
3931type ReportActionItemSingleProps = Partial < ChildrenProps > & {
4032 /** All the data of the action */
@@ -98,19 +90,7 @@ function ReportActionItemSingle({
9890 const mainAccountID = delegateAccountID ? ( reportPreviewSenderID ?? potentialIOUReport ?. ownerAccountID ?? action ?. childOwnerAccountID ) : undefined ;
9991 const currentUserPersonalDetails = useCurrentUserPersonalDetails ( ) ;
10092
101- // Vacation delegate details for submitted action
102- const vacationer = getVacationer ( action ) ;
103- const submittedTo = getSubmittedTo ( action ) ;
104- const vacationDelegateDetailsForSubmit = getPersonalDetailByEmail ( vacationer ?? '' ) ;
105- const submittedToDetails = getPersonalDetailByEmail ( submittedTo ?? '' ) ;
106-
107- // Vacation delegate details for approved action
108- const managerOnVacation = getManagerOnVacation ( action ) ;
109- const vacationDelegateDetailsForApprove = getPersonalDetailByEmail ( managerOnVacation ?? '' ) ;
110-
111- // Check if this is an automatic action
112- const originalMessage = getOriginalMessage ( action ) ;
113- const isAutomaticAction = originalMessage && 'automaticAction' in originalMessage ? originalMessage . automaticAction : false ;
93+ const hasVacationDelegate = ! ! getVacationer ( action ) || ! ! getManagerOnVacation ( action ) ;
11494
11595 const headingText = avatarType === CONST . REPORT_ACTION_AVATARS . TYPE . MULTIPLE ? `${ primaryAvatar . name } & ${ secondaryAvatar . name } ` : primaryAvatar . name ;
11696
@@ -233,18 +213,7 @@ function ReportActionItemSingle({
233213 />
234214 ) }
235215 { ! ! humanAgentAccountID && < HumanAgentAssistedByText action = { action } /> }
236- { ! ! vacationer && ! ! submittedTo && (
237- < Text style = { [ styles . chatDelegateMessage ] } >
238- { translate (
239- 'statusPage.toAsVacationDelegate' ,
240- submittedToDetails ?. displayName ?? submittedTo ?? '' ,
241- vacationDelegateDetailsForSubmit ?. displayName ?? vacationer ?? '' ,
242- ) }
243- </ Text >
244- ) }
245- { ! ! managerOnVacation && ! isAutomaticAction && (
246- < Text style = { [ styles . chatDelegateMessage ] } > { translate ( 'statusPage.asVacationDelegate' , vacationDelegateDetailsForApprove ?. displayName ?? managerOnVacation ?? '' ) } </ Text >
247- ) }
216+ { hasVacationDelegate && < VacationDelegateText action = { action } /> }
248217 < View style = { hasBeenFlagged ? styles . blockquote : { } } > { children } </ View >
249218 </ View >
250219 </ View >
0 commit comments