@@ -386,14 +386,15 @@ function buildTaskData(
386386 hasOutstandingChildTaskInParentReport : boolean ,
387387 hasOutstandingChildTask : boolean ,
388388 parentReportAction : OnyxEntry < ReportAction > | undefined ,
389+ delegateEmail : string | undefined ,
389390) : {
390391 optimisticData : Array < OnyxUpdate < typeof ONYXKEYS . COLLECTION . REPORT | typeof ONYXKEYS . COLLECTION . REPORT_ACTIONS > > ;
391392 failureData : Array < OnyxUpdate < typeof ONYXKEYS . COLLECTION . REPORT | typeof ONYXKEYS . COLLECTION . REPORT_ACTIONS > > ;
392393 successData : Array < OnyxUpdate < typeof ONYXKEYS . COLLECTION . REPORT_ACTIONS > > ;
393394 parameters : CompleteTaskParams ;
394395} {
395396 const message = `marked as complete` ;
396- const completedTaskReportAction = ReportUtils . buildOptimisticTaskReportAction ( taskReportID , CONST . REPORT . ACTIONS . TYPE . TASK_COMPLETED , message ) ;
397+ const completedTaskReportAction = ReportUtils . buildOptimisticTaskReportAction ( taskReportID , CONST . REPORT . ACTIONS . TYPE . TASK_COMPLETED , delegateEmail , message ) ;
397398 const optimisticData : Array < OnyxUpdate < typeof ONYXKEYS . COLLECTION . REPORT | typeof ONYXKEYS . COLLECTION . REPORT_ACTIONS > > = [
398399 {
399400 onyxMethod : Onyx . METHOD . MERGE ,
@@ -504,6 +505,7 @@ function completeTask(
504505 hasOutstandingChildTaskInParentReport : boolean ,
505506 hasOutstandingChildTask : boolean ,
506507 parentReportAction : OnyxEntry < ReportAction > | undefined ,
508+ delegateEmail : string | undefined ,
507509 reportIDFromAction ?: string ,
508510) : OnyxData < typeof ONYXKEYS . COLLECTION . REPORT | typeof ONYXKEYS . COLLECTION . REPORT_ACTIONS > {
509511 const taskReportID = taskReport ?. reportID ?? reportIDFromAction ;
@@ -518,6 +520,7 @@ function completeTask(
518520 hasOutstandingChildTaskInParentReport ,
519521 hasOutstandingChildTask ,
520522 parentReportAction ,
523+ delegateEmail ,
521524 ) ;
522525
523526 playSound ( SOUNDS . SUCCESS ) ;
@@ -528,13 +531,19 @@ function completeTask(
528531/**
529532 * Reopen a closed task
530533 */
531- function reopenTask ( taskReport : OnyxEntry < OnyxTypes . Report > , parentReport : OnyxEntry < OnyxTypes . Report > , currentUserAccountID : number , reportIDFromAction ?: string ) {
534+ function reopenTask (
535+ taskReport : OnyxEntry < OnyxTypes . Report > ,
536+ parentReport : OnyxEntry < OnyxTypes . Report > ,
537+ currentUserAccountID : number ,
538+ delegateEmail : string | undefined ,
539+ reportIDFromAction ?: string ,
540+ ) {
532541 const taskReportID = taskReport ?. reportID ?? reportIDFromAction ;
533542 if ( ! taskReportID ) {
534543 return ;
535544 }
536545 const message = `marked as incomplete` ;
537- const reopenedTaskReportAction = ReportUtils . buildOptimisticTaskReportAction ( taskReportID , CONST . REPORT . ACTIONS . TYPE . TASK_REOPENED , message ) ;
546+ const reopenedTaskReportAction = ReportUtils . buildOptimisticTaskReportAction ( taskReportID , CONST . REPORT . ACTIONS . TYPE . TASK_REOPENED , delegateEmail , message ) ;
538547 const hasOutstandingChildTask = taskReport ?. managerID === currentUserAccountID ? true : parentReport ?. hasOutstandingChildTask ;
539548
540549 const optimisticData : Array < OnyxUpdate < typeof ONYXKEYS . COLLECTION . REPORT | typeof ONYXKEYS . COLLECTION . REPORT_ACTIONS > > = [
@@ -1173,13 +1182,14 @@ function deleteTask(
11731182 hasOutstandingChildTask : boolean ,
11741183 parentReportAction : OnyxEntry < ReportAction > ,
11751184 conciergeReportID : string | undefined ,
1185+ delegateEmail : string | undefined ,
11761186 ancestors : ReportUtils . Ancestor [ ] = [ ] ,
11771187) {
11781188 if ( ! report ) {
11791189 return ;
11801190 }
11811191 const message = `deleted task: ${ report . reportName } ` ;
1182- const optimisticCancelReportAction = ReportUtils . buildOptimisticTaskReportAction ( report . reportID , CONST . REPORT . ACTIONS . TYPE . TASK_CANCELLED , message ) ;
1192+ const optimisticCancelReportAction = ReportUtils . buildOptimisticTaskReportAction ( report . reportID , CONST . REPORT . ACTIONS . TYPE . TASK_CANCELLED , delegateEmail , message ) ;
11831193 const optimisticReportActionID = optimisticCancelReportAction . reportActionID ;
11841194 const canUserPerformWriteAction = ReportUtils . canUserPerformWriteAction ( report , isReportArchived ) ;
11851195
@@ -1437,7 +1447,8 @@ function getFinishOnboardingTaskOnyxData(
14371447 if ( taskReport && canActionTask ( taskReport , parentReportAction , currentUserAccountID , taskParentReport , isParentReportArchived ) ) {
14381448 if ( taskReport ) {
14391449 if ( taskReport . stateNum !== CONST . REPORT . STATE_NUM . APPROVED || taskReport . statusNum !== CONST . REPORT . STATUS_NUM . APPROVED ) {
1440- return completeTask ( taskReport , taskParentReport ?. hasOutstandingChildTask ?? false , hasOutstandingChildTask , parentReportAction ) ;
1450+ // Will be refactored in next PR; full restructure tracked in https://github.com/Expensify/App/issues/66417
1451+ return completeTask ( taskReport , taskParentReport ?. hasOutstandingChildTask ?? false , hasOutstandingChildTask , parentReportAction , undefined ) ;
14411452 }
14421453 }
14431454 }
0 commit comments