Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
8 changes: 6 additions & 2 deletions src/components/ReportActionItem/TaskPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {delegateEmailSelector} from '@selectors/Account';
import React from 'react';
import {View} from 'react-native';
import type {StyleProp, ViewStyle} from 'react-native';
Expand All @@ -15,6 +16,7 @@ import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentU
import useHasOutstandingChildTask from '@hooks/useHasOutstandingChildTask';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useParentReport from '@hooks/useParentReport';
import useParentReportAction from '@hooks/useParentReportAction';
import useReportIsArchived from '@hooks/useReportIsArchived';
Expand All @@ -31,6 +33,7 @@ import Parser from '@libs/Parser';
import {isCanceledTaskReport, isOpenTaskReport, isReportManager} from '@libs/ReportUtils';
import type {ContextMenuAnchor} from '@pages/inbox/report/ContextMenu/ReportActionContextMenu';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {Report, ReportAction} from '@src/types/onyx';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
Expand Down Expand Up @@ -114,6 +117,7 @@ function TaskPreview({
const parentReport = useParentReport(taskContextReport?.reportID);
const isParentReportArchived = useReportIsArchived(parentReport?.reportID);
const hasOutstandingChildTask = useHasOutstandingChildTask(taskContextReport);
const [delegateEmail] = useOnyx(ONYXKEYS.ACCOUNT, {selector: delegateEmailSelector});
const isTaskActionable = canActionTask(taskContextReport, parentReportAction, currentUserPersonalDetails.accountID, parentReport, isParentReportArchived);
const hasAssignee = taskAssigneeAccountID > 0;
const personalDetails = usePersonalDetails();
Expand Down Expand Up @@ -163,9 +167,9 @@ function TaskPreview({
disabled={!isTaskActionable}
onPress={callFunctionIfActionIsAllowed(() => {
if (isTaskCompleted) {
reopenTask(taskContextReport, parentReport, currentUserPersonalDetails.accountID, taskReportID);
reopenTask(taskContextReport, parentReport, currentUserPersonalDetails.accountID, delegateEmail, taskReportID);
} else {
completeTask(taskContextReport, parentReport?.hasOutstandingChildTask ?? false, hasOutstandingChildTask, parentReportAction, taskReportID);
completeTask(taskContextReport, parentReport?.hasOutstandingChildTask ?? false, hasOutstandingChildTask, parentReportAction, delegateEmail, taskReportID);
}
})}
accessibilityLabel={translate('task.task')}
Expand Down
6 changes: 4 additions & 2 deletions src/components/ReportActionItem/TaskView.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {delegateEmailSelector} from '@selectors/Account';
import React, {useEffect, useMemo} from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
Expand Down Expand Up @@ -57,6 +58,7 @@ function TaskView({report, parentReport, action}: TaskViewProps) {
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [delegateEmail] = useOnyx(ONYXKEYS.ACCOUNT, {selector: delegateEmailSelector});

useEffect(() => {
setTaskReport(report);
Expand Down Expand Up @@ -151,9 +153,9 @@ function TaskView({report, parentReport, action}: TaskViewProps) {
return;
}
if (isCompleted) {
reopenTask(report, parentReport, currentUserPersonalDetails.accountID);
reopenTask(report, parentReport, currentUserPersonalDetails.accountID, delegateEmail);
} else {
completeTask(report, parentReport?.hasOutstandingChildTask ?? false, hasOutstandingChildTask, parentReportAction);
completeTask(report, parentReport?.hasOutstandingChildTask ?? false, hasOutstandingChildTask, parentReportAction, delegateEmail);
}
})}
isChecked={isCompleted}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {delegateEmailSelector} from '@selectors/Account';
import React from 'react';
import type {StyleProp, ViewStyle} from 'react-native';
import {View} from 'react-native';
Expand All @@ -10,6 +11,7 @@ import TextWithTooltip from '@components/TextWithTooltip';
import useHasOutstandingChildTask from '@hooks/useHasOutstandingChildTask';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useParentReport from '@hooks/useParentReport';
import useParentReportAction from '@hooks/useParentReportAction';
import useReportIsArchived from '@hooks/useReportIsArchived';
Expand All @@ -21,6 +23,7 @@ import {callFunctionIfActionIsAllowed} from '@libs/actions/Session';
import {canActionTask, completeTask} from '@libs/actions/Task';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Report} from '@src/types/onyx';
import AvatarWithTextCell from './AvatarWithTextCell';
import DateCell from './DateCell';
Expand Down Expand Up @@ -79,6 +82,7 @@ function ActionCell({taskItem, isLargeScreenWidth}: TaskCellProps) {
const isParentReportArchived = useReportIsArchived(parentReport?.reportID);
const hasOutstandingChildTask = useHasOutstandingChildTask(taskItem.report);
const parentReportAction = useParentReportAction(taskItem.report);
const [delegateEmail] = useOnyx(ONYXKEYS.ACCOUNT, {selector: delegateEmailSelector});
const isTaskActionable = canActionTask(taskItem.report, parentReportAction, session?.accountID, parentReport, isParentReportArchived);
const isTaskCompleted = taskItem.statusNum === CONST.REPORT.STATUS_NUM.APPROVED && taskItem.stateNum === CONST.REPORT.STATE_NUM.APPROVED;

Expand Down Expand Up @@ -108,7 +112,7 @@ function ActionCell({taskItem, isLargeScreenWidth}: TaskCellProps) {
style={[styles.w100]}
isDisabled={!isTaskActionable}
onPress={callFunctionIfActionIsAllowed(() => {
completeTask(taskItem as Report, parentReport?.hasOutstandingChildTask ?? false, hasOutstandingChildTask, parentReportAction, taskItem.reportID);
completeTask(taskItem as Report, parentReport?.hasOutstandingChildTask ?? false, hasOutstandingChildTask, parentReportAction, delegateEmail, taskItem.reportID);
})}
/>
);
Expand Down
8 changes: 6 additions & 2 deletions src/components/TaskHeaderActionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {delegateEmailSelector} from '@selectors/Account';
import React from 'react';
import {View} from 'react-native';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useHasOutstandingChildTask from '@hooks/useHasOutstandingChildTask';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useParentReport from '@hooks/useParentReport';
import useParentReportAction from '@hooks/useParentReportAction';
import useReportIsArchived from '@hooks/useReportIsArchived';
Expand All @@ -12,6 +14,7 @@ import {isActiveTaskEditRoute} from '@libs/TaskUtils';
import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {canActionTask, completeTask, reopenTask} from '@userActions/Task';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type * as OnyxTypes from '@src/types/onyx';
import Button from './Button';

Expand All @@ -28,6 +31,7 @@ function TaskHeaderActionButton({report}: TaskHeaderActionButtonProps) {
const isParentReportArchived = useReportIsArchived(parentReport?.reportID);
const hasOutstandingChildTask = useHasOutstandingChildTask(report);
const parentReportAction = useParentReportAction(report);
const [delegateEmail] = useOnyx(ONYXKEYS.ACCOUNT, {selector: delegateEmailSelector});
const isTaskActionable = canActionTask(report, parentReportAction, currentUserPersonalDetails?.accountID, parentReport, isParentReportArchived);

if (!canWriteInReport(report)) {
Expand All @@ -46,9 +50,9 @@ function TaskHeaderActionButton({report}: TaskHeaderActionButtonProps) {
return;
}
if (isCompletedTaskReport(report)) {
reopenTask(report, parentReport, currentUserPersonalDetails.accountID);
reopenTask(report, parentReport, currentUserPersonalDetails.accountID, delegateEmail);
} else {
completeTask(report, parentReport?.hasOutstandingChildTask ?? false, hasOutstandingChildTask, parentReportAction);
completeTask(report, parentReport?.hasOutstandingChildTask ?? false, hasOutstandingChildTask, parentReportAction, delegateEmail);
}
})}
style={styles.flex1}
Expand Down
8 changes: 6 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@
};

let conciergeReportIDOnyxConnect: OnyxEntry<string>;
Onyx.connect({

Check warning on line 1048 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.CONCIERGE_REPORT_ID,
callback: (value) => {
conciergeReportIDOnyxConnect = value;
Expand All @@ -1053,7 +1053,7 @@
});

const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon';
Onyx.connect({

Check warning on line 1056 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
// When signed out, val is undefined
Expand All @@ -1071,7 +1071,7 @@
let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
let allPersonalDetailLogins: string[];
let currentUserPersonalDetails: OnyxEntry<PersonalDetails>;
Onyx.connect({

Check warning on line 1074 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
if (deprecatedCurrentUserAccountID) {
Expand All @@ -1083,7 +1083,7 @@
});

let allReportsDraft: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 1086 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_DRAFT,
waitForCollectionCallback: true,
callback: (value) => (allReportsDraft = value),
Expand All @@ -1091,7 +1091,7 @@

let allPolicies: OnyxCollection<Policy>;
let policiesArray: Policy[] = [];
Onyx.connect({

Check warning on line 1094 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -1101,7 +1101,7 @@
});

let allPolicyDrafts: OnyxCollection<Policy>;
Onyx.connect({

Check warning on line 1104 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY_DRAFTS,
waitForCollectionCallback: true,
callback: (value) => (allPolicyDrafts = value),
Expand All @@ -1109,7 +1109,7 @@

let deprecatedAllReports: OnyxCollection<Report>;
let deprecatedReportsByPolicyID: ReportByPolicyMap;
Onyx.connect({

Check warning on line 1112 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -1145,14 +1145,14 @@
});

let betaConfiguration: OnyxEntry<BetaConfiguration> = {};
Onyx.connect({

Check warning on line 1148 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.BETA_CONFIGURATION,
callback: (value) => (betaConfiguration = value ?? {}),
});

let deprecatedAllTransactions: OnyxCollection<Transaction> = {};
let deprecatedReportsTransactions: Record<string, Transaction[]> = {};
Onyx.connect({

Check warning on line 1155 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -1178,7 +1178,7 @@
});

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 1181 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand Down Expand Up @@ -7794,6 +7794,7 @@
function buildOptimisticTaskReportAction(
taskReportID: string,
actionName: typeof CONST.REPORT.ACTIONS.TYPE.TASK_COMPLETED | typeof CONST.REPORT.ACTIONS.TYPE.TASK_REOPENED | typeof CONST.REPORT.ACTIONS.TYPE.TASK_CANCELLED,
delegateEmailParam: string | undefined,
message = '',
actorAccountID = deprecatedCurrentUserAccountID,
createdOffset = 0,
Expand All @@ -7805,7 +7806,9 @@
html: message,
whisperedTo: [],
};
const delegateAccountDetails = getPersonalDetailByEmail(delegateEmail);
// Falls back to module-level delegateEmail (from Onyx.connect) for callers not yet migrated; will be removed in https://github.com/Expensify/App/issues/66417
const effectiveDelegateEmail = delegateEmailParam ?? delegateEmail;
const delegateAccountDetails = effectiveDelegateEmail ? getPersonalDetailByEmail(effectiveDelegateEmail) : undefined;

return {
actionName,
Expand Down Expand Up @@ -11904,7 +11907,8 @@
}

const completedTaskReportAction = isTaskAutoCompleted
? buildOptimisticTaskReportAction(currentTask.reportID, CONST.REPORT.ACTIONS.TYPE.TASK_COMPLETED, 'marked as complete', actorAccountID, 2)
? // Will be refactored in next PR; full restructure tracked in https://github.com/Expensify/App/issues/66417
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) {
createWorkspaceTaskReportID = currentTask.reportID;
Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2923,7 +2923,8 @@ function buildPolicyData(options: BuildPolicyDataOptions): OnyxData<BuildPolicyD
optimisticData: optimisticCreateWorkspaceTaskData,
successData: successCreateWorkspaceTaskData,
failureData: failureCreateWorkspaceTaskData,
} = buildTaskData(createWorkspaceTaskReport, introSelected.createWorkspace, false, false, undefined);
// Will be refactored in next PR; full restructure tracked in https://github.com/Expensify/App/issues/66417
} = buildTaskData(createWorkspaceTaskReport, introSelected.createWorkspace, false, false, undefined, undefined);
optimisticData.push(...optimisticCreateWorkspaceTaskData);
successData.push(...successCreateWorkspaceTaskData);
failureData.push(...failureCreateWorkspaceTaskData);
Expand Down
21 changes: 16 additions & 5 deletions src/libs/actions/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,15 @@ function buildTaskData(
hasOutstandingChildTaskInParentReport: boolean,
hasOutstandingChildTask: boolean,
parentReportAction: OnyxEntry<ReportAction> | undefined,
delegateEmail: string | undefined,
): {
optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS>>;
failureData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS>>;
successData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS>>;
parameters: CompleteTaskParams;
} {
const message = `marked as complete`;
const completedTaskReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASK_COMPLETED, message);
const completedTaskReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASK_COMPLETED, delegateEmail, message);
const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS>> = [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down Expand Up @@ -504,6 +505,7 @@ function completeTask(
hasOutstandingChildTaskInParentReport: boolean,
hasOutstandingChildTask: boolean,
parentReportAction: OnyxEntry<ReportAction> | undefined,
delegateEmail: string | undefined,
reportIDFromAction?: string,
): OnyxData<typeof ONYXKEYS.COLLECTION.REPORT | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS> {
const taskReportID = taskReport?.reportID ?? reportIDFromAction;
Expand All @@ -518,6 +520,7 @@ function completeTask(
hasOutstandingChildTaskInParentReport,
hasOutstandingChildTask,
parentReportAction,
delegateEmail,
);

playSound(SOUNDS.SUCCESS);
Expand All @@ -528,13 +531,19 @@ function completeTask(
/**
* Reopen a closed task
*/
function reopenTask(taskReport: OnyxEntry<OnyxTypes.Report>, parentReport: OnyxEntry<OnyxTypes.Report>, currentUserAccountID: number, reportIDFromAction?: string) {
function reopenTask(
taskReport: OnyxEntry<OnyxTypes.Report>,
parentReport: OnyxEntry<OnyxTypes.Report>,
currentUserAccountID: number,
delegateEmail: string | undefined,
reportIDFromAction?: string,
) {
const taskReportID = taskReport?.reportID ?? reportIDFromAction;
if (!taskReportID) {
return;
}
const message = `marked as incomplete`;
const reopenedTaskReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASK_REOPENED, message);
const reopenedTaskReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASK_REOPENED, delegateEmail, message);
const hasOutstandingChildTask = taskReport?.managerID === currentUserAccountID ? true : parentReport?.hasOutstandingChildTask;

const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS>> = [
Expand Down Expand Up @@ -1173,13 +1182,14 @@ function deleteTask(
hasOutstandingChildTask: boolean,
parentReportAction: OnyxEntry<ReportAction>,
conciergeReportID: string | undefined,
delegateEmail: string | undefined,
ancestors: ReportUtils.Ancestor[] = [],
) {
if (!report) {
return;
}
const message = `deleted task: ${report.reportName}`;
const optimisticCancelReportAction = ReportUtils.buildOptimisticTaskReportAction(report.reportID, CONST.REPORT.ACTIONS.TYPE.TASK_CANCELLED, message);
const optimisticCancelReportAction = ReportUtils.buildOptimisticTaskReportAction(report.reportID, CONST.REPORT.ACTIONS.TYPE.TASK_CANCELLED, delegateEmail, message);
const optimisticReportActionID = optimisticCancelReportAction.reportActionID;
const canUserPerformWriteAction = ReportUtils.canUserPerformWriteAction(report, isReportArchived);

Expand Down Expand Up @@ -1437,7 +1447,8 @@ function getFinishOnboardingTaskOnyxData(
if (taskReport && canActionTask(taskReport, parentReportAction, currentUserAccountID, taskParentReport, isParentReportArchived)) {
if (taskReport) {
if (taskReport.stateNum !== CONST.REPORT.STATE_NUM.APPROVED || taskReport.statusNum !== CONST.REPORT.STATUS_NUM.APPROVED) {
return completeTask(taskReport, taskParentReport?.hasOutstandingChildTask ?? false, hasOutstandingChildTask, parentReportAction);
// Will be refactored in next PR; full restructure tracked in https://github.com/Expensify/App/issues/66417
return completeTask(taskReport, taskParentReport?.hasOutstandingChildTask ?? false, hasOutstandingChildTask, parentReportAction, undefined);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/Workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ function createApprovalWorkflow({approvalWorkflow, policy, addExpenseApprovalsTa
addExpenseApprovalsTaskReport &&
(addExpenseApprovalsTaskReport.stateNum !== CONST.REPORT.STATE_NUM.APPROVED || addExpenseApprovalsTaskReport.statusNum !== CONST.REPORT.STATUS_NUM.APPROVED)
) {
completeTask(addExpenseApprovalsTaskReport, false, false, undefined);
// Will be refactored in next PR; full restructure tracked in https://github.com/Expensify/App/issues/66417
completeTask(addExpenseApprovalsTaskReport, false, false, undefined, undefined);
}
}

Expand Down
18 changes: 16 additions & 2 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {StackActions} from '@react-navigation/native';
import {delegateEmailSelector} from '@selectors/Account';
import {validTransactionDraftIDsSelector} from '@selectors/TransactionDraft';
import React, {useCallback, useEffect, useMemo} from 'react';
import {InteractionManager, View} from 'react-native';
Expand Down Expand Up @@ -197,6 +198,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});
const [allTransactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
const [delegateEmail] = useOnyx(ONYXKEYS.ACCOUNT, {selector: delegateEmailSelector});
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const {showConfirmModal} = useConfirmModal();
const isPolicyAdmin = useMemo(() => isPolicyAdminUtil(policy), [policy]);
Expand Down Expand Up @@ -541,7 +543,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail
isAnonymousAction: false,
action: callFunctionIfActionIsAllowed(() => {
Navigation.goBack(backTo);
reopenTask(report, parentReport, currentUserPersonalDetails?.accountID);
reopenTask(report, parentReport, currentUserPersonalDetails?.accountID, delegateEmail);
}),
});
}
Expand Down Expand Up @@ -642,6 +644,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail
amountOwed,
ownerBillingGracePeriodEnd,
iouTransaction,
delegateEmail,
]);

const displayNamesWithTooltips = useMemo(() => {
Expand Down Expand Up @@ -890,7 +893,17 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail

const deleteTransaction = useCallback(() => {
if (caseID === CASES.DEFAULT) {
deleteTask(report, parentReport, isReportArchived, currentUserPersonalDetails.accountID, hasOutstandingChildTask, parentReportAction, conciergeReportID, ancestors);
deleteTask(
report,
parentReport,
isReportArchived,
currentUserPersonalDetails.accountID,
hasOutstandingChildTask,
parentReportAction,
conciergeReportID,
delegateEmail,
ancestors,
);
return;
}

Expand Down Expand Up @@ -943,6 +956,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail
deleteTransactions,
removeTransaction,
conciergeReportID,
delegateEmail,
]);

// Where to navigate back to after deleting the transaction and its report.
Expand Down
Loading
Loading