Skip to content

Commit

Permalink
pass report to setAssigneeValue from components itself
Browse files Browse the repository at this point in the history
  • Loading branch information
nexarvo committed Mar 28, 2024
1 parent aeeb77b commit 6e12a35
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
14 changes: 9 additions & 5 deletions src/libs/actions/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,12 +652,16 @@ function setAssigneeChatReport(chatReport: OnyxTypes.Report) {
* If there is no existing chat, it creates an optimistic chat report
* It also sets the shareDestination as that chat report if a share destination isn't already set
*/
function setAssigneeValue(assigneeEmail: string, assigneeAccountID: number, shareToReportID: string, isCurrentUser = false): OnyxEntry<OnyxTypes.Report> {
function setAssigneeValue(assigneeEmail: string, assigneeAccountID: number, shareToReportID: string, isCurrentUser = false, report: OnyxEntry<OnyxTypes.Report>): OnyxEntry<OnyxTypes.Report> {

Check failure on line 655 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Default parameters should be last
let chatReport: OnyxEntry<OnyxTypes.Report> = null;

if (!isCurrentUser) {
const reportID = shareToReportID;
chatReport = ReportUtils.getChatByReportID(reportID);
if(report) {
chatReport = report;
}
else {
chatReport = ReportUtils.getChatByParticipants([assigneeAccountID]);
}
if (!chatReport) {
chatReport = ReportUtils.buildOptimisticChatReport([assigneeAccountID]);
chatReport.isOptimisticReport = true;
Expand Down Expand Up @@ -710,14 +714,14 @@ function setParentReportID(parentReportID: string) {
/**
* Clears out the task info from the store and navigates to the NewTaskDetails page
*/
function clearOutTaskInfoAndNavigate(reportID: string, accountID = 0) {
function clearOutTaskInfoAndNavigate(reportID: string, accountID = 0, report: OnyxEntry<OnyxTypes.Report>) {

Check failure on line 717 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Default parameters should be last
clearOutTaskInfo();
if (reportID && reportID !== '0') {
setParentReportID(reportID);
}
if (accountID > 0) {
const accountLogin = allPersonalDetails?.[accountID]?.login ?? '';
setAssigneeValue(accountLogin, accountID, reportID);
setAssigneeValue(accountLogin, accountID, reportID, false, report);
}
Navigation.navigate(ROUTES.NEW_TASK_DETAILS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function AttachmentPickerWithMenuItems({
{
icon: Expensicons.Task,
text: translate('newTaskPage.assignTask'),
onSelected: () => Task.clearOutTaskInfoAndNavigate(reportID),
onSelected: () => Task.clearOutTaskInfoAndNavigate(reportID, 0, report),
},
];
}, [report, reportID, translate]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function FloatingActionButtonAndPopover(props) {
IOU.startMoneyRequest(CONST.IOU.TYPE.SEND, props.quickAction.chatReportID);
return;
case CONST.QUICK_ACTIONS.ASSIGN_TASK:
Task.clearOutTaskInfoAndNavigate(props.quickAction.chatReportID, _.get(props.quickAction, 'targetAccountID', 0));
Task.clearOutTaskInfoAndNavigate(props.quickAction.chatReportID, _.get(props.quickAction, 'targetAccountID', 0), quickActionReport);
return;
default:
return '';
Expand Down
2 changes: 2 additions & 0 deletions src/pages/tasks/TaskAssigneeSelectorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ function TaskAssigneeSelectorModal({reports, task}: TaskAssigneeSelectorModalPro
option?.accountID ?? -1,
report.reportID,
OptionsListUtils.isCurrentUser({...option, accountID: option?.accountID ?? -1, login: option?.login ?? ''}),
report,
);

// Pass through the selected assignee
Expand All @@ -194,6 +195,7 @@ function TaskAssigneeSelectorModal({reports, task}: TaskAssigneeSelectorModalPro
option.accountID,
task?.shareDestination ?? '',
OptionsListUtils.isCurrentUser({...option, accountID: option?.accountID ?? -1, login: option?.login ?? undefined}),
report,
);
Navigation.goBack(ROUTES.NEW_TASK);
}
Expand Down

0 comments on commit 6e12a35

Please sign in to comment.