Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ function MoneyReportHeaderSecondaryActionsInner({reportID, primaryAction, isRepo
amountOwed,
ownerBillingGracePeriodEnd,
delegateEmail,
ownerLogin: submitterLogin,
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {createTransactionThreadReport} from '@userActions/Report';

import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import {personalDetailsLoginSelector} from '@src/selectors/PersonalDetails';

import React from 'react';

Expand All @@ -31,6 +32,7 @@ function ReviewDuplicatesPrimaryAction({reportID, chatReportID}: SimpleActionPro
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [allTransactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
const [ownerLogin] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsLoginSelector(moneyRequestReport?.ownerAccountID)});

const {transactions: reportTransactionsMap} = useTransactionsAndViolationsForReport(moneyRequestReport?.reportID);
const transactions = Object.values(reportTransactionsMap);
Expand All @@ -48,6 +50,7 @@ function ReviewDuplicatesPrimaryAction({reportID, chatReportID}: SimpleActionPro
email ?? '',
accountID,
moneyRequestReport,
ownerLogin,
policy,
allTransactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + reportTransaction.transactionID],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';

import {delegateEmailSelector} from '@selectors/Account';
import {personalDetailsLoginSelector} from '@selectors/PersonalDetails';

function useConfirmApproval(reportID: string | undefined, startApprovedAnimation: () => void) {
const {accountID, email} = useCurrentUserPersonalDetails();
Expand All @@ -33,6 +34,7 @@ function useConfirmApproval(reportID: string | undefined, startApprovedAnimation
const [ownerBillingGracePeriodEnd] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const [allTransactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
const [delegateEmail] = useOnyx(ONYXKEYS.ACCOUNT, {selector: delegateEmailSelector});
const [ownerLogin] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsLoginSelector(moneyRequestReport?.ownerAccountID)});
const {transactions: reportTransactions} = useTransactionsAndViolationsForReport(moneyRequestReport?.reportID);

const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
Expand Down Expand Up @@ -63,6 +65,7 @@ function useConfirmApproval(reportID: string | undefined, startApprovedAnimation
userBillingGracePeriodEnds,
amountOwed,
ownerBillingGracePeriodEnd,
ownerLogin,
full: true,
onApproved: startApprovedAnimation,
delegateEmail,
Expand Down
4 changes: 3 additions & 1 deletion src/components/MoneyRequestHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import variables from '@styles/variables';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import SCREENS from '@src/SCREENS';
import {personalDetailsLoginSelector} from '@src/selectors/PersonalDetails';
import type IconAsset from '@src/types/utils/IconAsset';

import type {ReactNode} from 'react';
Expand Down Expand Up @@ -60,6 +61,7 @@ type MoneyRequestHeaderProps = {

function MoneyRequestHeader({reportID: reportIDProp, onBackButtonPress}: MoneyRequestHeaderProps) {
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportIDProp}`);
const [ownerLogin] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsLoginSelector(report?.ownerAccountID)});
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${getNonEmptyStringOnyxID(report?.policyID)}`);
const parentReportAction = useParentReportAction(report);

Expand Down Expand Up @@ -91,7 +93,7 @@ function MoneyRequestHeader({reportID: reportIDProp, onBackButtonPress}: MoneyRe

const isOnHold = isOnHoldTransactionUtils(transaction);
const isParentReportSettled = isSettledReportUtils(parentReport);
const isDuplicate = !isParentReportSettled && isDuplicateTransactionUtils(transaction, email ?? '', accountID, report, policy, transactionViolations);
const isDuplicate = !isParentReportSettled && isDuplicateTransactionUtils(transaction, email ?? '', accountID, report, ownerLogin, policy, transactionViolations);
const hasPendingRTERViolation = hasPendingRTERViolationTransactionUtils(transactionViolations);
const shouldShowBrokenConnectionViolation = shouldShowBrokenConnectionViolationTransactionUtils(parentReport, policy, transactionViolations);

Expand Down
4 changes: 3 additions & 1 deletion src/components/MoneyRequestHeaderPrimaryAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';

import {useRoute} from '@react-navigation/native';
import {personalDetailsLoginSelector} from '@selectors/PersonalDetails';
import React from 'react';
import {View} from 'react-native';

Expand Down Expand Up @@ -62,6 +63,7 @@ function MoneyRequestHeaderPrimaryAction({reportID}: MoneyRequestHeaderPrimaryAc
// Per-key Onyx subscriptions
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`);
const [parentOwnerLogin] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsLoginSelector(parentReport?.ownerAccountID)});
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`);
const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.parentReportID}`);
const parentReportAction = report?.parentReportActionID ? parentReportActions?.[report.parentReportActionID] : undefined;
Expand All @@ -78,7 +80,7 @@ function MoneyRequestHeaderPrimaryAction({reportID}: MoneyRequestHeaderPrimaryAc

const primaryAction =
report && parentReport && transaction
? getTransactionThreadPrimaryAction(currentUserLogin ?? '', accountID, report, parentReport, transaction, transactionViolations, policy, isFromReviewDuplicates)
? getTransactionThreadPrimaryAction(currentUserLogin ?? '', accountID, report, parentReport, parentOwnerLogin, transaction, transactionViolations, policy, isFromReviewDuplicates)
: '';

const renderButton = () => {
Expand Down
4 changes: 3 additions & 1 deletion src/components/MoneyRequestHeaderSecondaryActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import type {ValueOf} from 'type-fest';
import {useRoute} from '@react-navigation/native';
import {shouldFailAllRequestsSelector} from '@selectors/Network';
import {hasSeenTourSelector} from '@selectors/Onboarding';
import {personalDetailsLoginSelector} from '@selectors/PersonalDetails';
import {validTransactionDraftsSelector} from '@selectors/TransactionDraft';
import React, {useRef, useState} from 'react';

Expand Down Expand Up @@ -128,6 +129,7 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
// Per-key Onyx subscriptions
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`);
const [parentOwnerLogin] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsLoginSelector(parentReport?.ownerAccountID)});
const [grandParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${parentReport?.parentReportID}`);
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`);
const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.parentReportID}`);
Expand Down Expand Up @@ -195,7 +197,7 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
report &&
parentReport &&
transaction &&
getTransactionThreadPrimaryAction(currentUserLogin ?? '', accountID, report, parentReport, transaction, transactionViolations, policy, false)
getTransactionThreadPrimaryAction(currentUserLogin ?? '', accountID, report, parentReport, parentOwnerLogin, transaction, transactionViolations, policy, false)
);
const activePolicyExpenseChat = getPolicyExpenseChat(accountID, defaultExpensePolicy?.id);
const isPerDiemRequestOnNonDefaultWorkspace = isPerDiemRequest(transaction) && defaultExpensePolicy?.id !== policy?.id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import type {PendingAction} from '@src/types/onyx/OnyxCommon';
import type {LayoutChangeEvent, NativeScrollEvent, NativeSyntheticEvent, ScrollView as RNScrollView} from 'react-native';

import {findFocusedRoute, useFocusEffect} from '@react-navigation/native';
import {personalDetailsLoginSelector} from '@selectors/PersonalDetails';
import {validTransactionDraftIDsSelector} from '@selectors/TransactionDraft';
import isEmpty from 'lodash/isEmpty';
import React, {memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react';
Expand All @@ -106,6 +107,7 @@ function filterTransactionViolations(
email: string,
accountID: number,
report: OnyxTypes.Report,
ownerLogin: string | undefined,
policy: OnyxTypes.Policy | undefined,
): OnyxTypes.TransactionViolations {
if (!allViolations) {
Expand All @@ -115,7 +117,7 @@ function filterTransactionViolations(
if (!raw?.length) {
return EMPTY_VIOLATIONS;
}
const filtered = getVisibleTransactionViolations(transaction, raw, email, accountID, report, policy);
const filtered = getVisibleTransactionViolations(transaction, raw, email, accountID, report, ownerLogin, policy);
return filtered.length === 0 ? EMPTY_VIOLATIONS : filtered;
}

Expand Down Expand Up @@ -200,6 +202,7 @@ function MoneyRequestReportTransactionList({
const shouldShowBreakdown = shouldShowExpenseReportBreakDown || !!billableTotal || (!!taxTotal && isTaxEnabled);
const transactionsWithoutPendingDelete = useMemo(() => transactions.filter((t) => !isTransactionPendingDelete(t)), [transactions]);
const currentUserDetails = useCurrentUserPersonalDetails();
const [ownerLogin] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsLoginSelector(report?.ownerAccountID)});
const isReportArchived = useReportIsArchived(report?.reportID);
const shouldShowAddExpenseButton = canAddTransaction(report, isReportArchived) && isCurrentUserSubmitter(report);
const [userBillingGracePeriodEnds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
Expand Down Expand Up @@ -693,10 +696,10 @@ function MoneyRequestReportTransactionList({
const accountID = currentUserDetails.accountID ?? CONST.DEFAULT_NUMBER_ID;

for (const transaction of resolvedTransactions) {
map.set(transaction.transactionID, filterTransactionViolations(transaction, allTransactionViolations, email, accountID, report, policy ?? undefined));
map.set(transaction.transactionID, filterTransactionViolations(transaction, allTransactionViolations, email, accountID, report, ownerLogin, policy ?? undefined));
}
return map;
}, [resolvedTransactions, allTransactionViolations, currentUserDetails.email, currentUserDetails.accountID, report, policy]);
}, [resolvedTransactions, allTransactionViolations, currentUserDetails.email, currentUserDetails.accountID, report, ownerLogin, policy]);

const renderTransactionItem = (transaction: TransactionWithOptionalHighlight) => (
<MoneyRequestReportTransactionItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage';

import {delegateEmailSelector} from '@selectors/Account';
import {personalDetailsLoginSelector} from '@selectors/PersonalDetails';
import React from 'react';

type ApproveActionButtonProps = {
Expand Down Expand Up @@ -43,6 +44,7 @@ function ApproveActionButton({iouReportID, startApprovedAnimation, onHoldMenuOpe
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [delegateEmail] = useOnyx(ONYXKEYS.ACCOUNT, {selector: delegateEmailSelector});
const [ownerLogin] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsLoginSelector(iouReport?.ownerAccountID)});

const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
const hasViolations = hasViolationsReportUtils(iouReport?.reportID, transactionViolations, currentUserAccountID, currentUserEmail);
Expand Down Expand Up @@ -70,6 +72,7 @@ function ApproveActionButton({iouReportID, startApprovedAnimation, onHoldMenuOpe
userBillingGracePeriodEnds,
amountOwed,
ownerBillingGracePeriodEnd,
ownerLogin,
full: true,
onApproved: startApprovedAnimation,
delegateEmail,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import type {ValueOf} from 'type-fest';

import {delegateEmailSelector} from '@selectors/Account';
import {hasSeenTourSelector} from '@selectors/Onboarding';
import {personalDetailsLoginSelector} from '@selectors/PersonalDetails';
import React from 'react';

type PayActionButtonProps = {
Expand Down Expand Up @@ -86,6 +87,7 @@ function PayActionButton({
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const activePolicy = usePolicy(activePolicyID);
const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${iouReportID}`);
const [ownerLogin] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsLoginSelector(iouReport?.ownerAccountID)});
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${iouReport?.policyID}`);
const chatReportPolicy = usePolicy(chatReport?.policyID);
const [invoiceReceiverPolicy] = useOnyx(
Expand Down Expand Up @@ -164,6 +166,7 @@ function PayActionButton({
userBillingGracePeriodEnds,
amountOwed,
ownerBillingGracePeriodEnd,
ownerLogin,
full: true,
onApproved: startApprovedAnimation,
delegateEmail,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function ExpenseReportListItemInner<TItem extends ListItem>({
return reportItem?.transactions?.some((transaction) => {
const relevantViolations = (transaction.violations ?? []).filter(
(violation) =>
!isViolationDismissed(transaction, violation, currentUserDetails.email ?? '', currentUserDetails.accountID, reportForViolations, policyForViolations) &&
!isViolationDismissed(transaction, violation, currentUserDetails.email ?? '', currentUserDetails.accountID, reportForViolations, policyForViolations, submitterLogin) &&
shouldShowViolation(reportForViolations, policyForViolations, violation.name, currentUserDetails.email ?? '', false, transaction),
);

Expand All @@ -205,7 +205,7 @@ function ExpenseReportListItemInner<TItem extends ListItem>({
);
return violations.some((violation) => violation.name === CONST.VIOLATIONS.MISSING_ATTENDEES);
});
}, [reportItem, policyCategories, policyForViolations, reportForViolations, currentUserDetails]);
}, [reportItem, policyCategories, policyForViolations, reportForViolations, currentUserDetails, submitterLogin]);

const {isDelegateAccessRestricted} = useDelegateNoAccessState();
const {showDelegateNoAccessModal} = useDelegateNoAccessActions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function TransactionListItemInner<TItem extends ListItem>({

const onyxViolations = (transactionViolationsForRow ?? []).filter(
(violation: TransactionViolation) =>
!isViolationDismissed(transactionItem, violation, currentUserDetails.email ?? '', currentUserDetails.accountID, reportForViolations, policyForViolations) &&
!isViolationDismissed(transactionItem, violation, currentUserDetails.email ?? '', currentUserDetails.accountID, reportForViolations, policyForViolations, submitterLogin) &&
shouldShowViolation(reportForViolations, policyForViolations, violation.name, currentUserDetails.email ?? '', false, transactionItem),
);

Expand Down
3 changes: 3 additions & 0 deletions src/components/SettlementButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import type {TupleToUnion} from 'type-fest';

import {delegateEmailSelector, isUserValidatedSelector} from '@selectors/Account';
import {hasSeenTourSelector} from '@selectors/Onboarding';
import {personalDetailsLoginSelector} from '@selectors/PersonalDetails';
import truncate from 'lodash/truncate';
import React, {useCallback, useContext} from 'react';
import {View} from 'react-native';
Expand Down Expand Up @@ -125,6 +126,7 @@ function SettlementButton({
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${chatReportID || CONST.DEFAULT_NUMBER_ID}`);
const [conciergeReportID = ''] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const [iouReportNextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${iouReport?.reportID}`);
const [ownerLogin] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsLoginSelector(iouReport?.ownerAccountID)});
const [isUserValidated] = useOnyx(ONYXKEYS.ACCOUNT, {selector: isUserValidatedSelector});
const [amountOwed] = useOnyx(ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED);
const policyEmployeeAccountIDs = getPolicyEmployeeAccountIDs(policy, accountID);
Expand Down Expand Up @@ -524,6 +526,7 @@ function SettlementButton({
userBillingGracePeriodEnds,
amountOwed,
ownerBillingGracePeriodEnd,
ownerLogin,
full: false,
delegateEmail,
});
Expand Down
3 changes: 3 additions & 0 deletions src/hooks/useHoldMenuSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {OnyxEntry} from 'react-native-onyx';

import {delegateEmailSelector} from '@selectors/Account';
import {hasSeenTourSelector} from '@selectors/Onboarding';
import {personalDetailsLoginSelector} from '@selectors/PersonalDetails';

import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails';
import useOnyx from './useOnyx';
Expand Down Expand Up @@ -48,6 +49,7 @@ function useHoldMenuSubmit({moneyRequestReport, chatReport, requestType, payment
const [delegateEmail] = useOnyx(ONYXKEYS.ACCOUNT, {selector: delegateEmailSelector});
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const [moneyRequestReportNextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${moneyRequestReport?.reportID}`);
const [ownerLogin] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsLoginSelector(moneyRequestReport?.ownerAccountID)});
const {isBetaEnabled} = usePermissions();
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
Expand Down Expand Up @@ -86,6 +88,7 @@ function useHoldMenuSubmit({moneyRequestReport, chatReport, requestType, payment
userBillingGracePeriodEnds,
amountOwed,
ownerBillingGracePeriodEnd,
ownerLogin,
full,
onApproved: animationCallback,
expenseReportPolicy: policy,
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useLifecycleActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ function useLifecycleActions({reportID, startApprovedAnimation, startAnimation,
userBillingGracePeriodEnds,
amountOwed,
ownerBillingGracePeriodEnd,
ownerLogin: submitterLogin,
full: true,
onApproved: () => {
if (skipAnimation) {
Expand Down
Loading
Loading