File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -424,6 +424,23 @@ function setShareDestinationValue(shareDestination) {
424
424
Onyx . merge ( ONYXKEYS . TASK , { shareDestination} ) ;
425
425
}
426
426
427
+ /**
428
+ * Auto-assign participant when creating a task in a DM
429
+ * @param {String } reportID
430
+ */
431
+
432
+ function setAssigneeValueWithParentReportID ( reportID ) {
433
+ const report = ReportUtils . getReport ( reportID ) ;
434
+ const isDefault = ! ( ReportUtils . isChatRoom ( report ) || ReportUtils . isPolicyExpenseChat ( report ) ) ;
435
+ const participants = lodashGet ( report , 'participants' , [ ] ) ;
436
+ const hasMultipleParticipants = participants . length > 1 ;
437
+ if ( ! isDefault || hasMultipleParticipants || report . parentReportID ) {
438
+ return ;
439
+ }
440
+
441
+ Onyx . merge ( ONYXKEYS . TASK , { assignee : participants [ 0 ] } ) ;
442
+ }
443
+
427
444
/**
428
445
* Sets the assignee value for the task and checks for an existing chat with the assignee
429
446
* If there is no existing chat, it creates an optimistic chat report
@@ -591,6 +608,7 @@ export {
591
608
setTaskReport ,
592
609
setDetailsValue ,
593
610
setAssigneeValue ,
611
+ setAssigneeValueWithParentReportID ,
594
612
setShareDestinationValue ,
595
613
clearOutTaskInfo ,
596
614
reopenTask ,
Original file line number Diff line number Diff line change @@ -86,6 +86,12 @@ const NewTaskPage = (props) => {
86
86
setAssignee ( displayDetails ) ;
87
87
}
88
88
89
+ // If we don't have an assignee and we are creating a task from a report
90
+ // this allows us to auto assign a participant of the report.
91
+ if ( ! props . task . assignee && props . task . parentReportID ) {
92
+ TaskUtils . setAssigneeValueWithParentReportID ( props . task . parentReportID ) ;
93
+ }
94
+
89
95
// We only set the parentReportID if we are creating a task from a report
90
96
// this allows us to go ahead and set that report as the share destination
91
97
// and disable the share destination selector
You can’t perform that action at this time.
0 commit comments