@@ -34,6 +34,11 @@ type BuildNextStepNewParams = {
3434 shouldFixViolations ?: boolean ;
3535 isUnapprove ?: boolean ;
3636 isReopen ?: boolean ;
37+ /**
38+ * Bypass Next Approver ID is used when an approver is bypassed so that we can show the next approver in the chain.
39+ * This is necessary in the case where report actions are not yet updated to determine the bypass action.
40+ */
41+ bypassNextApproverID ?: number ;
3742} ;
3843
3944function buildNextStepMessage ( nextStep : ReportNextStep , translate : LocaleContextProps [ 'translate' ] , currentUserAccountID : number ) : string {
@@ -61,8 +66,19 @@ function buildNextStepMessage(nextStep: ReportNextStep, translate: LocaleContext
6166}
6267
6368function buildOptimisticNextStep ( params : BuildNextStepNewParams ) : ReportNextStep | null {
64- const { report, policy, currentUserAccountIDParam, currentUserEmailParam, hasViolations, isASAPSubmitBetaEnabled, predictedNextStatus, shouldFixViolations, isUnapprove, isReopen} =
65- params ;
69+ const {
70+ report,
71+ policy,
72+ currentUserAccountIDParam,
73+ currentUserEmailParam,
74+ hasViolations,
75+ isASAPSubmitBetaEnabled,
76+ predictedNextStatus,
77+ shouldFixViolations,
78+ isUnapprove,
79+ isReopen,
80+ bypassNextApproverID,
81+ } = params ;
6682
6783 if ( ! isExpenseReport ( report ) ) {
6884 return null ;
@@ -77,7 +93,7 @@ function buildOptimisticNextStep(params: BuildNextStepNewParams): ReportNextStep
7793 ( ( report . total !== 0 && report . total !== undefined ) ||
7894 ( report . unheldTotal !== 0 && report . unheldTotal !== undefined ) ||
7995 ( report . unheldNonReimbursableTotal !== 0 && report . unheldNonReimbursableTotal !== undefined ) ) ;
80- const approverAccountID = getNextApproverAccountID ( report , isUnapprove ) ;
96+ const approverAccountID = bypassNextApproverID ?? getNextApproverAccountID ( report , isUnapprove ) ;
8197 const reimburserAccountID = getReimburserAccountID ( policy ) ;
8298 const hasValidAccount = ! ! policy ?. achAccount ?. accountNumber || policy ?. reimbursementChoice !== CONST . POLICY . REIMBURSEMENT_CHOICES . REIMBURSEMENT_YES ;
8399
@@ -331,8 +347,19 @@ function buildOptimisticNextStepForStrictPolicyRuleViolations() {
331347 * @deprecated This function will be removed soon. You should still use it though but also use buildOptimisticNextStep in parallel.
332348 */
333349function buildNextStepNew ( params : BuildNextStepNewParams ) : ReportNextStepDeprecated | null {
334- const { report, policy, currentUserAccountIDParam, currentUserEmailParam, hasViolations, isASAPSubmitBetaEnabled, predictedNextStatus, shouldFixViolations, isUnapprove, isReopen} =
335- params ;
350+ const {
351+ report,
352+ policy,
353+ currentUserAccountIDParam,
354+ currentUserEmailParam,
355+ hasViolations,
356+ isASAPSubmitBetaEnabled,
357+ predictedNextStatus,
358+ shouldFixViolations,
359+ isUnapprove,
360+ isReopen,
361+ bypassNextApproverID,
362+ } = params ;
336363
337364 if ( ! isExpenseReport ( report ) ) {
338365 return null ;
@@ -360,8 +387,10 @@ function buildNextStepNew(params: BuildNextStepNewParams): ReportNextStepDepreca
360387 policyOwnerPersonalDetails ?. displayName ??
361388 policyOwnerPersonalDetails ?. login ??
362389 getDisplayNameForParticipant ( { accountID : policy ?. ownerAccountID , formatPhoneNumber : formatPhoneNumberPhoneUtils } ) ;
363- const nextApproverDisplayName = getNextApproverDisplayName ( report , isUnapprove ) ;
364- const approverAccountID = getNextApproverAccountID ( report , isUnapprove ) ;
390+ const nextApproverDisplayName = bypassNextApproverID
391+ ? ( getDisplayNameForParticipant ( { accountID : bypassNextApproverID , formatPhoneNumber : formatPhoneNumberPhoneUtils } ) ?? getPersonalDetailsForAccountID ( bypassNextApproverID ) . login )
392+ : getNextApproverDisplayName ( report , isUnapprove ) ;
393+ const approverAccountID = bypassNextApproverID ?? getNextApproverAccountID ( report , isUnapprove ) ;
365394 const approvers = getLoginsByAccountIDs ( [ approverAccountID ?? CONST . DEFAULT_NUMBER_ID ] ) ;
366395
367396 const reimburserAccountID = getReimburserAccountID ( policy ) ;
0 commit comments