Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8610,7 +8610,12 @@ function buildOptimisticCardAssignedReportAction(assigneeAccountID: number, curr
};
}

function buildOptimisticChangedTaskAssigneeReportAction(assigneeAccountID: number, currentUserAccountID: number, delegateEmailParam: string | undefined): OptimisticEditedTaskReportAction {
function buildOptimisticChangedTaskAssigneeReportAction(
assigneeAccountID: number,
currentUserAccountID: number,
delegateEmailParam: string | undefined,
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'],
): OptimisticEditedTaskReportAction {
const delegateAccountDetails = delegateEmailParam ? getPersonalDetailByEmail(delegateEmailParam) : undefined;

return {
Expand All @@ -8621,7 +8626,7 @@ function buildOptimisticChangedTaskAssigneeReportAction(assigneeAccountID: numbe
message: [
{
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
text: `assigned to ${getDisplayNameForParticipant({accountID: assigneeAccountID, formatPhoneNumber: formatPhoneNumberPhoneUtils})}`,
text: `assigned to ${getDisplayNameForParticipant({accountID: assigneeAccountID, formatPhoneNumber})}`,
html: `assigned to <mention-user accountID="${assigneeAccountID}"/>`,
},
],
Expand Down
9 changes: 8 additions & 1 deletion src/libs/actions/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type EditTaskAssigneeOptions = {
assigneeAccountID?: number | null;
assigneeChatReport?: OnyxEntry<OnyxTypes.Report>;
isOptimisticReport?: boolean;
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
};

type OptimisticReport = Pick<OnyxTypes.Report, 'reportName' | 'managerID' | 'pendingFields' | 'participants'>;
Expand Down Expand Up @@ -788,9 +789,15 @@ function editTaskAssignee({
assigneeAccountID = 0,
assigneeChatReport,
isOptimisticReport,
formatPhoneNumber,
}: EditTaskAssigneeOptions) {
// Create the EditedReportAction on the task
const editTaskReportAction = ReportUtils.buildOptimisticChangedTaskAssigneeReportAction(assigneeAccountID ?? CONST.DEFAULT_NUMBER_ID, currentUserAccountID, delegateEmail);
const editTaskReportAction = ReportUtils.buildOptimisticChangedTaskAssigneeReportAction(
assigneeAccountID ?? CONST.DEFAULT_NUMBER_ID,
currentUserAccountID,
delegateEmail,
formatPhoneNumber,
);
const reportName = report.reportName?.trim();

let assigneeChatReportOnyxData;
Expand Down
3 changes: 2 additions & 1 deletion src/pages/tasks/DynamicTaskAssigneeSelectorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function DynamicTaskAssigneeSelectorModal() {
| PlatformStackRouteProp<TaskDetailsNavigatorParamList, typeof SCREENS.DYNAMIC_TASK_ASSIGNEE>
| PlatformStackRouteProp<NewTaskNavigatorParamList, typeof SCREENS.NEW_TASK.DYNAMIC_TASK_ASSIGNEE>
>();
const {translate} = useLocalize();
const {translate, formatPhoneNumber} = useLocalize();
const isNewTaskFlow = route.name === SCREENS.NEW_TASK.DYNAMIC_TASK_ASSIGNEE;
const backPath = useDynamicBackPath(isNewTaskFlow ? DYNAMIC_ROUTES.NEW_TASK_ASSIGNEE.path : DYNAMIC_ROUTES.TASK_ASSIGNEE.path);
const reportID = !isNewTaskFlow && route.params && 'reportID' in route.params ? route.params.reportID : undefined;
Expand Down Expand Up @@ -176,6 +176,7 @@ function DynamicTaskAssigneeSelectorModal() {
assigneeAccountID: option?.accountID,
assigneeChatReport,
isOptimisticReport,
formatPhoneNumber,
});
}
Navigation.goBack(backPath);
Expand Down
2 changes: 2 additions & 0 deletions tests/actions/TaskTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,7 @@ describe('actions/Task', () => {
hasOutstandingChildTask: false,
delegateEmail: DELEGATE_EMAIL,
assigneeAccountID: ASSIGNEE_ACCOUNT_ID,
formatPhoneNumber,
});

const calls = mockWrite.mock.calls;
Expand Down Expand Up @@ -1414,6 +1415,7 @@ describe('actions/Task', () => {
hasOutstandingChildTask: false,
delegateEmail: undefined,
assigneeAccountID: ASSIGNEE_ACCOUNT_ID,
formatPhoneNumber,
});

const calls = mockWrite.mock.calls;
Expand Down
Loading