Skip to content
Draft
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
32 changes: 26 additions & 6 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6844,6 +6844,7 @@
* @param taskAssigneeAccountID - AccountID of the person assigned to the task
* @param text - Text of the comment
* @param parentReportID - Report ID of the parent report
* @param delegateAccountID - AccountID of the delegate acting on behalf of the current user
* @param createdOffset - The offset for task's created time that created via a loop
*/
function buildOptimisticTaskCommentReportAction(
Expand All @@ -6852,13 +6853,20 @@
taskAssigneeAccountID: number,
text: string,
parentReportID: string | undefined,
delegateAccountID: number | undefined,
actorAccountID?: number,
createdOffset = 0,
currentUserEmail?: string,
currentUserAccountID?: number,
): OptimisticReportAction {
// delegateAccountIDParam: will be threaded in PR 14; buildOptimisticAddCommentReportAction falls back to module-level Onyx.connect value (https://github.com/Expensify/App/issues/66425)
const reportAction = buildOptimisticAddCommentReportAction({text, reportID: taskReportID, createdOffset, currentUserEmail, currentUserAccountID, delegateAccountIDParam: undefined});
const reportAction = buildOptimisticAddCommentReportAction({
text,
reportID: taskReportID,
createdOffset,
currentUserEmail,
currentUserAccountID,
delegateAccountIDParam: delegateAccountID,
});
if (Array.isArray(reportAction.reportAction.message)) {
const message = reportAction.reportAction.message.at(0);
if (message) {
Expand Down Expand Up @@ -10896,7 +10904,7 @@
/**
* Returns the onyx data needed for the task assignee chat
*/
function getTaskAssigneeChatOnyxData(

Check failure on line 10907 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / ESLint check

Function 'getTaskAssigneeChatOnyxData' has too many parameters (11). Maximum allowed is 10

Check failure on line 10907 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / ESLint check

Function 'getTaskAssigneeChatOnyxData' has too many parameters (11). Maximum allowed is 10
accountID: number,
assigneeAccountID: number,
taskReportID: string,
Expand All @@ -10906,6 +10914,7 @@
assigneeChatReport: OnyxEntry<Report>,
currentUserEmail: string,
currentUserAccountID: number,
delegateAccountID: number | undefined,
isOptimisticAssigneeChatReport?: boolean,
): OnyxDataTaskAssigneeChat {
// Set if we need to add a comment to the assignee chat notifying them that they have been assigned a task
Expand Down Expand Up @@ -11027,6 +11036,7 @@
assigneeAccountID,
`assigned to ${displayname}`,
parentReportID,
delegateAccountID,
undefined,
0,
currentUserEmail,
Expand Down Expand Up @@ -12320,7 +12330,7 @@

// Text message
const message = typeof onboardingMessage.message === 'function' ? onboardingMessage.message(onboardingTaskParams) : onboardingMessage.message;
// delegateAccountIDParam: will be threaded in PR 14; buildOptimisticAddCommentReportAction falls back to module-level Onyx.connect value (https://github.com/Expensify/App/issues/66425)
// delegateAccountIDParam: will be threaded in PR 15b; buildOptimisticAddCommentReportAction falls back to module-level Onyx.connect value (https://github.com/Expensify/App/issues/66425)
const textComment = buildOptimisticAddCommentReportAction({text: message, actorAccountID, createdOffset: 1, delegateAccountIDParam: undefined});
const textCommentAction: OptimisticAddCommentReportAction = textComment.reportAction;
const textMessage: AddCommentOrAttachmentParams = {
Expand Down Expand Up @@ -12373,7 +12383,17 @@
);
const emailCreatingAction = CONST.EMAIL.CONCIERGE;
const taskCreatedAction = buildOptimisticCreatedReportAction({emailCreatingAction});
const taskReportAction = buildOptimisticTaskCommentReportAction(currentTask.reportID, taskTitle, 0, `task for ${taskTitle}`, targetChatReportID, actorAccountID, index + 3);
// delegateAccountID: will be threaded in PR 15b; buildOptimisticAddCommentReportAction falls back to module-level Onyx.connect value (https://github.com/Expensify/App/issues/66425)
const taskReportAction = buildOptimisticTaskCommentReportAction(
currentTask.reportID,
taskTitle,
0,
`task for ${taskTitle}`,
targetChatReportID,
undefined,
actorAccountID,
index + 3,
);
currentTask.parentReportActionID = taskReportAction.reportAction.reportActionID;

let isTaskAutoCompleted: boolean = task.autoCompleted;
Expand All @@ -12389,7 +12409,7 @@
}

const completedTaskReportAction = isTaskAutoCompleted
? // delegateEmailParam: will be threaded in PR 14; buildOptimisticTaskReportAction falls back to module-level Onyx.connect value (https://github.com/Expensify/App/issues/66425)
? // delegateEmailParam: will be threaded in PR 17; buildOptimisticTaskReportAction falls back to module-level Onyx.connect value (https://github.com/Expensify/App/issues/66425)
buildOptimisticTaskReportAction(currentTask.reportID, CONST.REPORT.ACTIONS.TYPE.TASK_COMPLETED, undefined, 'marked as complete', actorAccountID, 2)
: null;
if (task.type === CONST.ONBOARDING_TASK_TYPE.CREATE_WORKSPACE) {
Expand Down Expand Up @@ -12418,7 +12438,7 @@
// Sign-off welcome message
const welcomeSignOffText =
engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? translateLocal('onboarding.welcomeSignOffTitleManageTeam') : translateLocal('onboarding.welcomeSignOffTitle');
// delegateAccountIDParam: will be threaded in PR 14; buildOptimisticAddCommentReportAction falls back to module-level Onyx.connect value (https://github.com/Expensify/App/issues/66425)
// delegateAccountIDParam: will be threaded in PR 15b; buildOptimisticAddCommentReportAction falls back to module-level Onyx.connect value (https://github.com/Expensify/App/issues/66425)
const welcomeSignOffComment = buildOptimisticAddCommentReportAction({text: welcomeSignOffText, actorAccountID, createdOffset: tasksData.length + 3, delegateAccountIDParam: undefined});
const welcomeSignOffCommentAction: OptimisticAddCommentReportAction = welcomeSignOffComment.reportAction;
const welcomeSignOffMessage = {
Expand Down
8 changes: 7 additions & 1 deletion src/libs/actions/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type EditTaskAssigneeOptions = {
currentUserAccountID: number;
hasOutstandingChildTask: boolean;
delegateEmail: string | undefined;
delegateAccountID: number | undefined;
assigneeAccountID?: number | null;
assigneeChatReport?: OnyxEntry<OnyxTypes.Report>;
isOptimisticReport?: boolean;
Expand Down Expand Up @@ -76,6 +77,7 @@ type CreateTaskAndNavigateParams = {
assigneeEmail: string;
currentUserAccountID: number;
currentUserEmail: string;
delegateAccountID: number | undefined;
assigneeAccountID?: number;
assigneeChatReport?: OnyxEntry<OnyxTypes.Report>;
policyID?: string;
Expand Down Expand Up @@ -128,6 +130,7 @@ function createTaskAndNavigate(params: CreateTaskAndNavigateParams) {
currentUserEmail,
currentUserDisplayName,
currentUserAvatar,
delegateAccountID,
assigneeAccountID = 0,
assigneeChatReport,
policyID = CONST.POLICY.OWNER_EMAIL_FAKE,
Expand Down Expand Up @@ -164,7 +167,7 @@ function createTaskAndNavigate(params: CreateTaskAndNavigateParams) {
currentUserEmail,
currentUserAvatar,
});
const optimisticAddCommentReport = ReportUtils.buildOptimisticTaskCommentReportAction(taskReportID, title, assigneeAccountID, `task for ${title}`, parentReportID);
const optimisticAddCommentReport = ReportUtils.buildOptimisticTaskCommentReportAction(taskReportID, title, assigneeAccountID, `task for ${title}`, parentReportID, delegateAccountID);
optimisticTaskReport.parentReportActionID = optimisticAddCommentReport.reportAction.reportActionID;

const currentTime = getDBTimeWithSkew();
Expand Down Expand Up @@ -268,6 +271,7 @@ function createTaskAndNavigate(params: CreateTaskAndNavigateParams) {
assigneeChatReport,
currentUserEmail,
currentUserAccountID,
delegateAccountID,
);

optimisticData.push(...assigneeChatReportOnyxData.optimisticData);
Expand Down Expand Up @@ -791,6 +795,7 @@ function editTaskAssignee({
currentUserAccountID,
hasOutstandingChildTask,
delegateEmail,
delegateAccountID,
assigneeAccountID = 0,
assigneeChatReport,
isOptimisticReport,
Expand Down Expand Up @@ -917,6 +922,7 @@ function editTaskAssignee({
assigneeChatReport,
currentUserEmail,
currentUserAccountID,
delegateAccountID,
isOptimisticReport,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ function useComposerSubmit(reportID: string) {
currentUserEmail,
currentUserDisplayName: currentUserPersonalDetails.displayName,
currentUserAvatar: currentUserPersonalDetails.avatar,
delegateAccountID,
assigneeAccountID: assignee?.accountID,
assigneeChatReport,
policyID: report?.policyID,
Expand Down
3 changes: 3 additions & 0 deletions src/pages/tasks/DynamicNewTaskDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import TextInput from '@components/TextInput';
import useAncestors from '@hooks/useAncestors';
import useAutoFocusInput from '@hooks/useAutoFocusInput';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useDelegateAccountID from '@hooks/useDelegateAccountID';
import useDynamicBackPath from '@hooks/useDynamicBackPath';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
Expand Down Expand Up @@ -38,6 +39,7 @@ function DynamicNewTaskDetailsPage() {
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${task?.parentReportID}`);
const ancestors = useAncestors(parentReport);
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const delegateAccountID = useDelegateAccountID();
const [taskCreatorAndAssigneeDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {
selector: personalDetailsListSelector([currentUserPersonalDetails.accountID, task?.assigneeAccountID]),
});
Expand Down Expand Up @@ -89,6 +91,7 @@ function DynamicNewTaskDetailsPage() {
currentUserEmail: currentUserPersonalDetails.email ?? '',
currentUserDisplayName: currentUserPersonalDetails.displayName,
currentUserAvatar: currentUserPersonalDetails.avatar,
delegateAccountID,
assigneeAccountID: task.assigneeAccountID,
assigneeChatReport: task.assigneeChatReport,
policyID: CONST.POLICY.OWNER_EMAIL_FAKE,
Expand Down
3 changes: 3 additions & 0 deletions src/pages/tasks/DynamicNewTaskPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ScrollView from '@components/ScrollView';

import useAncestors from '@hooks/useAncestors';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useDelegateAccountID from '@hooks/useDelegateAccountID';
import useDynamicBackPath from '@hooks/useDynamicBackPath';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
Expand Down Expand Up @@ -42,6 +43,7 @@ function DynamicNewTaskPage() {
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const reportAttributes = useReportAttributes();
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const delegateAccountID = useDelegateAccountID();
const [taskCreatorAndAssigneeDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {
selector: personalDetailsListSelector([currentUserPersonalDetails.accountID, task?.assigneeAccountID]),
});
Expand Down Expand Up @@ -115,6 +117,7 @@ function DynamicNewTaskPage() {
currentUserEmail: currentUserPersonalDetails.email ?? '',
currentUserDisplayName: currentUserPersonalDetails.displayName,
currentUserAvatar: currentUserPersonalDetails.avatar,
delegateAccountID,
assigneeAccountID: task.assigneeAccountID,
assigneeChatReport: task.assigneeChatReport,
policyID: parentReport?.policyID,
Expand Down
3 changes: 3 additions & 0 deletions src/pages/tasks/DynamicTaskAssigneeSelectorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import SelectionListWithSections from '@components/SelectionList/SelectionListWi
import type {ListItem} from '@components/SelectionList/types';

import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useDelegateAccountID from '@hooks/useDelegateAccountID';
import useDynamicBackPath from '@hooks/useDynamicBackPath';
import useHasOutstandingChildTask from '@hooks/useHasOutstandingChildTask';
import useLocalize from '@hooks/useLocalize';
Expand Down Expand Up @@ -54,6 +55,7 @@ function DynamicTaskAssigneeSelectorModal() {
const [isSearchingForReports] = useOnyx(ONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTS);
const [countryCode = CONST.DEFAULT_COUNTRY_CODE] = useOnyx(ONYXKEYS.COUNTRY_CODE);
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const delegateAccountID = useDelegateAccountID();
const currentUserEmail = currentUserPersonalDetails.email ?? '';
const [delegateEmail] = useOnyx(ONYXKEYS.ACCOUNT, {
selector: delegateEmailSelector,
Expand Down Expand Up @@ -173,6 +175,7 @@ function DynamicTaskAssigneeSelectorModal() {
currentUserAccountID: currentUserPersonalDetails.accountID,
hasOutstandingChildTask,
delegateEmail,
delegateAccountID,
assigneeAccountID: option?.accountID,
assigneeChatReport,
isOptimisticReport,
Expand Down
Loading
Loading