Skip to content
1 change: 1 addition & 0 deletions src/components/AddExistingExpenseFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function AddExistingExpenseFooter({selectedIds, report, reportToConfirm, policy,
isTrackIntentUser,
personalPolicyOutputCurrency: personalPolicy?.outputCurrency,
selfDMReportActions,
delegateAccountID,
getCurrencyDecimals,
});
}
Expand Down
24 changes: 22 additions & 2 deletions src/components/MoneyReportHeaderEducationalModals.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useDelegateAccountID from '@hooks/useDelegateAccountID';
import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';

Expand Down Expand Up @@ -49,6 +50,7 @@ function MoneyReportHeaderEducationalModals({reportID, ref}: MoneyReportHeaderEd
const [shouldFailAllRequests] = useOnyx(ONYXKEYS.NETWORK, {selector: shouldFailAllRequestsSelector});

const {login: currentUserLogin, accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
const delegateAccountID = useDelegateAccountID();

const [moneyRequestReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(moneyRequestReport?.chatReportID)}`);
Expand All @@ -66,15 +68,33 @@ function MoneyReportHeaderEducationalModals({reportID, ref}: MoneyReportHeaderEd
setIsHoldEducationalModalVisible(false);
setNameValuePair(ONYXKEYS.NVP_DISMISSED_HOLD_USE_EXPLANATION, true, false, !shouldFailAllRequests);
if (requestParentReportAction) {
changeMoneyRequestHoldStatus(requestParentReportAction, transaction, isOffline, currentUserLogin ?? '', currentUserAccountID, transactionViolations, isTrackIntentUser);
changeMoneyRequestHoldStatus(
requestParentReportAction,
transaction,
isOffline,
currentUserLogin ?? '',
currentUserAccountID,
transactionViolations,
isTrackIntentUser,
delegateAccountID,
);
}
};

const dismissRejectModalBasedOnAction = () => {
if (rejectModalAction === CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.HOLD) {
dismissRejectUseExplanation();
if (requestParentReportAction) {
changeMoneyRequestHoldStatus(requestParentReportAction, transaction, isOffline, currentUserLogin ?? '', currentUserAccountID, transactionViolations, isTrackIntentUser);
changeMoneyRequestHoldStatus(
requestParentReportAction,
transaction,
isOffline,
currentUserLogin ?? '',
currentUserAccountID,
transactionViolations,
isTrackIntentUser,
delegateAccountID,
);
}
} else if (rejectModalAction === CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.REJECT_BULK) {
dismissRejectUseExplanation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Button from '@components/ButtonComposed';
import {useDelegateNoAccessActions, useDelegateNoAccessState} from '@components/DelegateNoAccessModalProvider';

import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useDelegateAccountID from '@hooks/useDelegateAccountID';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useTransactionsAndViolationsForReport from '@hooks/useTransactionsAndViolationsForReport';
Expand All @@ -27,6 +28,7 @@ function RemoveHoldPrimaryAction({reportID, chatReportID}: SimpleActionProps) {
const {showDelegateNoAccessModal} = useDelegateNoAccessActions();

const {login: currentUserLogin, accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
const delegateAccountID = useDelegateAccountID();
const {moneyRequestReport, isOffline, reportActions, transactionThreadReportID, requestParentReportAction} = useTransactionThreadData(reportID, chatReportID);
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${getNonEmptyStringOnyxID(moneyRequestReport?.policyID)}`);
const [allTransactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
Expand All @@ -51,7 +53,16 @@ function RemoveHoldPrimaryAction({reportID, chatReportID}: SimpleActionProps) {
for (const action of IOUActions) {
const linkedTransaction = getLinkedIOUTransaction(action, transactions);
const transactionViolations = allTransactionViolations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${linkedTransaction?.transactionID}`];
changeMoneyRequestHoldStatus(action, linkedTransaction, isOffline, currentUserLogin ?? '', currentUserAccountID, transactionViolations, isTrackIntentUser);
changeMoneyRequestHoldStatus(
action,
linkedTransaction,
isOffline,
currentUserLogin ?? '',
currentUserAccountID,
transactionViolations,
isTrackIntentUser,
delegateAccountID,
);
}
return;
}
Expand All @@ -63,7 +74,16 @@ function RemoveHoldPrimaryAction({reportID, chatReportID}: SimpleActionProps) {

const linkedTransaction = getLinkedIOUTransaction(moneyRequestAction, transactions);
const transactionViolations = allTransactionViolations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${linkedTransaction?.transactionID}`];
changeMoneyRequestHoldStatus(moneyRequestAction, linkedTransaction, isOffline, currentUserLogin ?? '', currentUserAccountID, transactionViolations, isTrackIntentUser);
changeMoneyRequestHoldStatus(
moneyRequestAction,
linkedTransaction,
isOffline,
currentUserLogin ?? '',
currentUserAccountID,
transactionViolations,
isTrackIntentUser,
delegateAccountID,
);
}}
>
<Button.Text>{translate('iou.unhold')}</Button.Text>
Expand Down
13 changes: 12 additions & 1 deletion src/components/MoneyRequestHeaderPrimaryAction.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useDelegateAccountID from '@hooks/useDelegateAccountID';
import useDuplicateTransactionsAndViolations from '@hooks/useDuplicateTransactionsAndViolations';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
Expand Down Expand Up @@ -46,6 +47,7 @@ function MoneyRequestHeaderPrimaryAction({reportID}: MoneyRequestHeaderPrimaryAc
const styles = useThemeStyles();
const {translate} = useLocalize();
const {login: currentUserLogin, accountID} = useCurrentUserPersonalDetails();
const delegateAccountID = useDelegateAccountID();
const {isDelegateAccessRestricted} = useDelegateNoAccessState();
const {showDelegateNoAccessModal} = useDelegateNoAccessActions();
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
Expand Down Expand Up @@ -97,7 +99,16 @@ function MoneyRequestHeaderPrimaryAction({reportID}: MoneyRequestHeaderPrimaryAc
showDelegateNoAccessModal();
return;
}
changeMoneyRequestHoldStatus(parentReportAction, transaction, isOffline, currentUserLogin ?? '', accountID, rawTransactionViolations, isTrackIntentUser);
changeMoneyRequestHoldStatus(
parentReportAction,
transaction,
isOffline,
currentUserLogin ?? '',
accountID,
rawTransactionViolations,
isTrackIntentUser,
delegateAccountID,
);
}}
/>
);
Expand Down
17 changes: 13 additions & 4 deletions src/components/MoneyRequestHeaderSecondaryActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,15 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
setIsHoldEducationalModalVisible(false);
setNameValuePair(ONYXKEYS.NVP_DISMISSED_HOLD_USE_EXPLANATION, true, false, !shouldFailAllRequests);
if (parentReportAction) {
changeMoneyRequestHoldStatus(parentReportAction, transaction, isOffline, currentUserLogin ?? '', accountID, rawTransactionViolations, isTrackIntentUser);
changeMoneyRequestHoldStatus(parentReportAction, transaction, isOffline, currentUserLogin ?? '', accountID, rawTransactionViolations, isTrackIntentUser, delegateAccountID);
}
};

const dismissRejectModalBasedOnAction = () => {
if (rejectModalAction === CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.HOLD) {
dismissRejectUseExplanation();
if (parentReportAction) {
changeMoneyRequestHoldStatus(parentReportAction, transaction, isOffline, currentUserLogin ?? '', accountID, rawTransactionViolations, isTrackIntentUser);
changeMoneyRequestHoldStatus(parentReportAction, transaction, isOffline, currentUserLogin ?? '', accountID, rawTransactionViolations, isTrackIntentUser, delegateAccountID);
}
} else {
dismissRejectUseExplanation();
Expand Down Expand Up @@ -352,7 +352,16 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
const shouldShowHoldEducationalModal = isReportSubmitter || isParentChatReportDM;
const isDismissed = shouldShowHoldEducationalModal ? dismissedHoldUseExplanation : dismissedRejectUseExplanation;
if (isDismissed) {
changeMoneyRequestHoldStatus(parentReportAction, transaction, isOffline, currentUserLogin ?? '', accountID, rawTransactionViolations, isTrackIntentUser);
changeMoneyRequestHoldStatus(
parentReportAction,
transaction,
isOffline,
currentUserLogin ?? '',
accountID,
rawTransactionViolations,
isTrackIntentUser,
delegateAccountID,
);
} else if (shouldShowHoldEducationalModal) {
setIsHoldEducationalModalVisible(true);
} else {
Expand All @@ -374,7 +383,7 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
return;
}

changeMoneyRequestHoldStatus(parentReportAction, transaction, isOffline, currentUserLogin ?? '', accountID, rawTransactionViolations, isTrackIntentUser);
changeMoneyRequestHoldStatus(parentReportAction, transaction, isOffline, currentUserLogin ?? '', accountID, rawTransactionViolations, isTrackIntentUser, delegateAccountID);
},
},
[CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.SPLIT]: {
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useExpenseActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic
reportTransactions,
allTransactionViolations,
bankAccountList,
delegateAccountID,
hash: currentSearchHash,
});
}, CONST.EXPENSE_REPORT_DELETE_DELAY_MS);
Expand Down
24 changes: 22 additions & 2 deletions src/hooks/useHoldRejectActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {ValueOf} from 'type-fest';
import {isTrackIntentUserSelector} from '@selectors/Onboarding';

import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails';
import useDelegateAccountID from './useDelegateAccountID';
import useGetIOUReportFromReportAction from './useGetIOUReportFromReportAction';
import {useMemoizedLazyExpensifyIcons} from './useLazyAsset';
import useLocalize from './useLocalize';
Expand Down Expand Up @@ -46,6 +47,7 @@ function useHoldRejectActions({reportID, onHoldEducationalOpen, onRejectModalOpe
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(moneyRequestReport?.chatReportID)}`);
const {iouTransactionID, requestParentReportAction} = useMoneyReportTransactionThread();
const {login: currentUserLogin, accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
const delegateAccountID = useDelegateAccountID();

const {chatReport: chatIOUReport} = useGetIOUReportFromReportAction(requestParentReportAction);

Expand Down Expand Up @@ -80,7 +82,16 @@ function useHoldRejectActions({reportID, onHoldEducationalOpen, onRejectModalOpe
const isDismissed = shouldShowHoldEducationalModal ? dismissedHoldUseExplanation : dismissedRejectUseExplanation;

if (isDismissed || shouldSuppressPromotionalUI) {
changeMoneyRequestHoldStatus(requestParentReportAction, transaction, isOffline, currentUserLogin ?? '', currentUserAccountID, transactionViolations, isTrackIntentUser);
changeMoneyRequestHoldStatus(
requestParentReportAction,
transaction,
isOffline,
currentUserLogin ?? '',
currentUserAccountID,
transactionViolations,
isTrackIntentUser,
delegateAccountID,
);
} else if (shouldShowHoldEducationalModal) {
onHoldEducationalOpen();
} else {
Expand All @@ -103,7 +114,16 @@ function useHoldRejectActions({reportID, onHoldEducationalOpen, onRejectModalOpe
return;
}

changeMoneyRequestHoldStatus(requestParentReportAction, transaction, isOffline, currentUserLogin ?? '', currentUserAccountID, transactionViolations, isTrackIntentUser);
changeMoneyRequestHoldStatus(
requestParentReportAction,
transaction,
isOffline,
currentUserLogin ?? '',
currentUserAccountID,
transactionViolations,
isTrackIntentUser,
delegateAccountID,
);
},
},
[CONST.REPORT.SECONDARY_ACTIONS.REJECT]: {
Expand Down
5 changes: 5 additions & 0 deletions src/hooks/useSearchBulkActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
reportTransactions: validTransactions,
allTransactionViolations,
bankAccountList,
delegateAccountID,
hash,
});
}
Expand Down Expand Up @@ -1134,6 +1135,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
reportTransactions: validTransactions,
allTransactionViolations: transactionsViolations,
bankAccountList,
delegateAccountID,
});
}
}
Expand All @@ -1159,6 +1161,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
deleteTransactionsFromHook,
duplicateTransactions,
duplicateTransactionViolations,
delegateAccountID,
]);

const onBulkPaySelected = useCallback(
Expand Down Expand Up @@ -2195,6 +2198,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
accountID,
transactionViolations,
isTrackIntentUser,
delegateAccountID,
);
}
clearSelectedTransactions();
Expand Down Expand Up @@ -2455,6 +2459,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
allReportsShouldMarkAsDone,
noReportsShouldMarkAsDone,
queryJSON?.groupBy,
delegateAccountID,
]);

const handleOfflineModalClose = useCallback(() => {
Expand Down
4 changes: 3 additions & 1 deletion src/hooks/useSelectedTransactionsActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import useConfirmModal from './useConfirmModal';
import {useCurrencyListActions} from './useCurrencyList';
import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails';
import useDefaultExpensePolicy from './useDefaultExpensePolicy';
import useDelegateAccountID from './useDelegateAccountID';
import useDeleteTransactions from './useDeleteTransactions';
import useDuplicateTransactionsAndViolations from './useDuplicateTransactionsAndViolations';
import useEnvironment from './useEnvironment';
Expand Down Expand Up @@ -128,6 +129,7 @@ function useSelectedTransactionsActions({
const {isBetaEnabled} = usePermissions();
const {deleteTransactions, shouldOpenSplitExpenseEditFlowOnDelete} = useDeleteTransactions({report, reportActions, policy});
const {login, accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
const delegateAccountID = useDelegateAccountID();
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);
const defaultExpensePolicy = useDefaultExpensePolicy();
const {isProduction} = useEnvironment();
Expand Down Expand Up @@ -359,7 +361,7 @@ function useSelectedTransactionsActions({
continue;
}
const transactionViolations = allTransactionViolations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`];
unholdRequest(transactionID, action.childReportID, policy, isOffline, login ?? '', currentUserAccountID, transactionViolations, isTrackIntentUser);
unholdRequest(transactionID, action.childReportID, policy, isOffline, login ?? '', currentUserAccountID, transactionViolations, isTrackIntentUser, delegateAccountID);
}
clearSelectedTransactions(true);
},
Expand Down
3 changes: 3 additions & 0 deletions src/hooks/useUndeleteTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import {isTrackIntentUserSelector} from '@selectors/Onboarding';

import {useCurrencyListActions} from './useCurrencyList';
import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails';
import useDelegateAccountID from './useDelegateAccountID';
import useOnyx from './useOnyx';
import usePermissions from './usePermissions';

function useUndeleteTransactions() {
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const delegateAccountID = useDelegateAccountID();
const {getCurrencyDecimals} = useCurrencyListActions();
const {isBetaEnabled} = usePermissions();
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
Expand Down Expand Up @@ -42,6 +44,7 @@ function useUndeleteTransactions() {
selfDMReportActions,
isTrackIntentUser,
personalPolicyOutputCurrency: policy?.outputCurrency,
delegateAccountID,
getCurrencyDecimals,
});
};
Expand Down
Loading
Loading