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
18 changes: 10 additions & 8 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
const personalDetails = usePersonalDetails();
const defaultExpensePolicy = useDefaultExpensePolicy();
const activePolicyExpenseChat = getPolicyExpenseChat(accountID, defaultExpensePolicy?.id);
const [userBillingGraceEndPeriodCollection] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${moneyRequestReport?.chatReportID}`);
const [nextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${moneyRequestReport?.reportID}`);
const [isUserValidated] = useOnyx(ONYXKEYS.ACCOUNT, {selector: isUserValidatedSelector});
Expand Down Expand Up @@ -623,6 +623,7 @@
activePolicy,
policy,
betas,
userBillingGraceEndPeriods,
});
if (currentSearchQueryJSON && !isOffline) {
search({
Expand Down Expand Up @@ -657,6 +658,7 @@
shouldCalculateTotals,
currentSearchResults?.search?.isLoading,
betas,
userBillingGraceEndPeriods,
],
);

Expand Down Expand Up @@ -685,7 +687,7 @@
setIsHoldMenuVisible(true);
} else {
startApprovedAnimation();
approveMoneyRequest(moneyRequestReport, policy, accountID, email ?? '', hasViolations, isASAPSubmitBetaEnabled, nextStep, betas, true);
approveMoneyRequest(moneyRequestReport, policy, accountID, email ?? '', hasViolations, isASAPSubmitBetaEnabled, nextStep, betas, userBillingGraceEndPeriods, true);
}
};

Expand Down Expand Up @@ -938,9 +940,8 @@
});

const addExpenseDropdownOptions = useMemo(
() =>
getAddExpenseDropdownOptions(translate, expensifyIcons, moneyRequestReport?.reportID, policy, userBillingGraceEndPeriodCollection, undefined, undefined, lastDistanceExpenseType),
[moneyRequestReport?.reportID, policy, userBillingGraceEndPeriodCollection, lastDistanceExpenseType, expensifyIcons, translate],
() => getAddExpenseDropdownOptions(translate, expensifyIcons, moneyRequestReport?.reportID, policy, userBillingGraceEndPeriods, undefined, undefined, lastDistanceExpenseType),
[moneyRequestReport?.reportID, policy, userBillingGraceEndPeriods, lastDistanceExpenseType, expensifyIcons, translate],
);

const exportSubmenuOptions: Record<string, DropdownOption<string>> = useMemo(() => {
Expand Down Expand Up @@ -1050,7 +1051,7 @@
return;
}
startSubmittingAnimation();
submitReport(moneyRequestReport, policy, accountID, email ?? '', hasViolations, isASAPSubmitBetaEnabled, nextStep);
submitReport(moneyRequestReport, policy, accountID, email ?? '', hasViolations, isASAPSubmitBetaEnabled, nextStep, userBillingGraceEndPeriods);
if (currentSearchQueryJSON && !isOffline) {
search({
searchKey: currentSearchKey,
Expand Down Expand Up @@ -1304,7 +1305,7 @@
showDWEModal();
return;
}
submitReport(moneyRequestReport, policy, accountID, email ?? '', hasViolations, isASAPSubmitBetaEnabled, nextStep);
submitReport(moneyRequestReport, policy, accountID, email ?? '', hasViolations, isASAPSubmitBetaEnabled, nextStep, userBillingGraceEndPeriods);
},
},
[CONST.REPORT.SECONDARY_ACTIONS.APPROVE]: {
Expand Down Expand Up @@ -1646,7 +1647,7 @@
if (!moneyRequestReport?.reportID) {
return;
}
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriodCollection)) {
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriods)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
Expand Down Expand Up @@ -1776,7 +1777,7 @@
}
return option;
});
}, [originalSelectedTransactionsOptions, showDeleteModal, dismissedRejectUseExplanation]);

Check warning on line 1780 in src/components/MoneyReportHeader.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useMemo has missing dependencies: 'isDelegateAccessRestricted' and 'showDelegateNoAccessModal'. Either include them or remove the dependency array

Check warning on line 1780 in src/components/MoneyReportHeader.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useMemo has missing dependencies: 'isDelegateAccessRestricted' and 'showDelegateNoAccessModal'. Either include them or remove the dependency array

const shouldShowSelectedTransactionsButton = !!selectedTransactionsOptions.length && !transactionThreadReportID;

Expand Down Expand Up @@ -1813,6 +1814,7 @@
iouReport: moneyRequestReport,
iouReportNextStep: nextStep,
betas,
userBillingGraceEndPeriods,
});

const showNextStepBar = shouldShowNextStep && !!(optimisticNextStep?.message?.length ?? (optimisticNextStep && 'messageKey' in optimisticNextStep));
Expand Down
3 changes: 3 additions & 0 deletions src/components/ProcessMoneyReportHoldMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function ProcessMoneyReportHoldMenu({
// We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to apply the correct modal type
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
const {isSmallScreenWidth} = useResponsiveLayout();
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const activePolicy = usePolicy(activePolicyID);
const policy = usePolicy(moneyRequestReport?.policyID);
Expand Down Expand Up @@ -104,6 +105,7 @@ function ProcessMoneyReportHoldMenu({
isASAPSubmitBetaEnabled,
moneyRequestReportNextStep,
betas,
userBillingGraceEndPeriods,
full,
);
} else if (chatReport && paymentType) {
Expand All @@ -121,6 +123,7 @@ function ProcessMoneyReportHoldMenu({
activePolicy,
policy,
betas,
userBillingGraceEndPeriods,
});
}
onClose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function MoneyRequestReportPreviewContent({
onPress,
forwardedFSClass,
}: MoneyRequestReportPreviewContentProps) {
const [userBillingGraceEndPeriodCollection] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [chatReportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${chatReportID}`, {allowStaleData: true});
const [iouReportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${iouReportID}`);
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
Expand Down Expand Up @@ -287,6 +287,7 @@ function MoneyRequestReportPreviewContent({
activePolicy,
policy,
betas,
userBillingGraceEndPeriods,
});
}
}
Expand All @@ -305,6 +306,7 @@ function MoneyRequestReportPreviewContent({
activePolicy,
policy,
betas,
userBillingGraceEndPeriods,
],
);

Expand Down Expand Up @@ -334,7 +336,18 @@ function MoneyRequestReportPreviewContent({
setIsHoldMenuVisible(true);
} else {
startApprovedAnimation();
approveMoneyRequest(iouReport, activePolicy, currentUserAccountID, currentUserEmail, hasViolations, isASAPSubmitBetaEnabled, iouReportNextStep, betas, true);
approveMoneyRequest(
iouReport,
activePolicy,
currentUserAccountID,
currentUserEmail,
hasViolations,
isASAPSubmitBetaEnabled,
iouReportNextStep,
betas,
userBillingGraceEndPeriods,
true,
);
}
};

Expand Down Expand Up @@ -640,12 +653,12 @@ function MoneyRequestReportPreviewContent({
expensifyIcons,
iouReport?.reportID,
policy,
userBillingGraceEndPeriodCollection,
userBillingGraceEndPeriods,
chatReportID,
iouReport?.parentReportID,
lastDistanceExpenseType,
),
[translate, expensifyIcons, iouReport?.reportID, iouReport?.parentReportID, policy, userBillingGraceEndPeriodCollection, chatReportID, lastDistanceExpenseType],
[translate, expensifyIcons, iouReport?.reportID, iouReport?.parentReportID, policy, userBillingGraceEndPeriods, chatReportID, lastDistanceExpenseType],
);

const isReportDeleted = action?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
Expand All @@ -662,7 +675,7 @@ function MoneyRequestReportPreviewContent({
return;
}
startSubmittingAnimation();
submitReport(iouReport, policy, currentUserAccountID, currentUserEmail, hasViolations, isASAPSubmitBetaEnabled, iouReportNextStep);
submitReport(iouReport, policy, currentUserAccountID, currentUserEmail, hasViolations, isASAPSubmitBetaEnabled, iouReportNextStep, userBillingGraceEndPeriods);
}}
isSubmittingAnimationRunning={isSubmittingAnimationRunning}
onAnimationFinish={stopAnimation}
Expand Down
3 changes: 1 addition & 2 deletions src/components/SettlementButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ 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 [isUserValidated] = useOnyx(ONYXKEYS.ACCOUNT, {selector: isUserValidatedSelector});
const policyEmployeeAccountIDs = getPolicyEmployeeAccountIDs(policy, accountID);
const reportBelongsToWorkspace = policyID ? doesReportBelongToWorkspace(chatReport, policyEmployeeAccountIDs, policyID, conciergeReportID) : false;
Expand Down Expand Up @@ -470,7 +469,7 @@ function SettlementButton({
if (confirmApproval) {
confirmApproval();
} else {
approveMoneyRequest(iouReport, policy, accountID, email ?? '', hasViolations, isASAPSubmitBetaEnabled, iouReportNextStep, betas, false);
approveMoneyRequest(iouReport, policy, accountID, email ?? '', hasViolations, isASAPSubmitBetaEnabled, iouReportNextStep, betas, userBillingGraceEndPeriods, false);
}
return;
}
Expand Down
10 changes: 6 additions & 4 deletions src/libs/PaymentUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import isEmpty from 'lodash/isEmpty';
import type {GestureResponderEvent} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import type {Merge, ValueOf} from 'type-fest';
import type {DropdownOption} from '@components/ButtonWithDropdownMenu/types';
import getBankIcon from '@components/Icon/BankIcons';
Expand All @@ -11,7 +11,7 @@ import type {BankAccountMenuItem} from '@components/Search/types';
import type {ThemeStyles} from '@styles/index';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import type {Beta, Policy, Report, ReportNextStepDeprecated} from '@src/types/onyx';
import type {Beta, BillingGraceEndPeriod, Policy, Report, ReportNextStepDeprecated} from '@src/types/onyx';
import type BankAccount from '@src/types/onyx/BankAccount';
import type Fund from '@src/types/onyx/Fund';
import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage';
Expand Down Expand Up @@ -42,6 +42,7 @@ type SelectPaymentTypeParams = {
iouReport?: OnyxEntry<Report>;
iouReportNextStep: OnyxEntry<ReportNextStepDeprecated>;
betas: OnyxEntry<Beta[]>;
userBillingGraceEndPeriods: OnyxCollection<BillingGraceEndPeriod>;
};

/**
Expand Down Expand Up @@ -178,8 +179,9 @@ const selectPaymentType = (params: SelectPaymentTypeParams) => {
iouReport,
iouReportNextStep,
betas,
userBillingGraceEndPeriods,
} = params;
if (policy && shouldRestrictUserBillableActions(policy.id)) {
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriods)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
Expand All @@ -197,7 +199,7 @@ const selectPaymentType = (params: SelectPaymentTypeParams) => {
if (confirmApproval) {
confirmApproval();
} else {
approveMoneyRequest(iouReport, policy, currentAccountID, currentEmail, hasViolations, isASAPSubmitBetaEnabled, iouReportNextStep, betas, true);
approveMoneyRequest(iouReport, policy, currentAccountID, currentEmail, hasViolations, isASAPSubmitBetaEnabled, iouReportNextStep, betas, userBillingGraceEndPeriods, true);
}
return;
}
Expand Down
24 changes: 20 additions & 4 deletions src/libs/actions/IOU/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@
};

let allPersonalDetails: OnyxTypes.PersonalDetailsList = {};
Onyx.connect({

Check warning on line 812 in src/libs/actions/IOU/index.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) => {
allPersonalDetails = value ?? {};
Expand Down Expand Up @@ -894,6 +894,7 @@
introSelected: OnyxEntry<OnyxTypes.IntroSelected>;
iouReportCurrentNextStepDeprecated: OnyxEntry<OnyxTypes.ReportNextStepDeprecated>;
currentUserAccountID: number;
userBillingGraceEndPeriods: OnyxCollection<OnyxTypes.BillingGraceEndPeriod>;
paymentPolicyID?: string;
full?: boolean;
activePolicy?: OnyxEntry<OnyxTypes.Policy>;
Expand All @@ -902,7 +903,7 @@
};

let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 906 in src/libs/actions/IOU/index.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 @@ -916,7 +917,7 @@
});

let allTransactionDrafts: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 920 in src/libs/actions/IOU/index.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_DRAFT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -925,7 +926,7 @@
});

let allTransactionViolations: NonNullable<OnyxCollection<OnyxTypes.TransactionViolations>> = {};
Onyx.connect({

Check warning on line 929 in src/libs/actions/IOU/index.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_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -939,7 +940,7 @@
});

let allPolicyTags: OnyxCollection<OnyxTypes.PolicyTagLists> = {};
Onyx.connect({

Check warning on line 943 in src/libs/actions/IOU/index.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_TAGS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -952,7 +953,7 @@
});

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

Check warning on line 956 in src/libs/actions/IOU/index.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 All @@ -961,7 +962,7 @@
});

let allReportNameValuePairs: OnyxCollection<OnyxTypes.ReportNameValuePairs>;
Onyx.connect({

Check warning on line 965 in src/libs/actions/IOU/index.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_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -971,7 +972,7 @@

let userAccountID = -1;
let currentUserEmail = '';
Onyx.connect({

Check warning on line 975 in src/libs/actions/IOU/index.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) => {
currentUserEmail = value?.email ?? '';
Expand All @@ -980,7 +981,7 @@
});

let deprecatedCurrentUserPersonalDetails: OnyxEntry<OnyxTypes.PersonalDetails>;
Onyx.connect({

Check warning on line 984 in src/libs/actions/IOU/index.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) => {
deprecatedCurrentUserPersonalDetails = value?.[userAccountID] ?? undefined;
Expand Down Expand Up @@ -10573,13 +10574,14 @@
isASAPSubmitBetaEnabled: boolean,
expenseReportCurrentNextStepDeprecated: OnyxEntry<OnyxTypes.ReportNextStepDeprecated>,
betas: OnyxEntry<OnyxTypes.Beta[]>,
userBillingGraceEndPeriods: OnyxCollection<OnyxTypes.BillingGraceEndPeriod>,
full?: boolean,
) {
if (!expenseReport) {
return;
}

if (expenseReport.policyID && shouldRestrictUserBillableActions(expenseReport.policyID)) {
if (expenseReport.policyID && shouldRestrictUserBillableActions(expenseReport.policyID, userBillingGraceEndPeriods)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(expenseReport.policyID));
return;
}
Expand Down Expand Up @@ -11455,11 +11457,12 @@
hasViolations: boolean,
isASAPSubmitBetaEnabled: boolean,
expenseReportCurrentNextStepDeprecated: OnyxEntry<OnyxTypes.ReportNextStepDeprecated>,
userBillingGraceEndPeriods: OnyxCollection<OnyxTypes.BillingGraceEndPeriod>,
) {
if (!expenseReport) {
return;
}
if (expenseReport.policyID && shouldRestrictUserBillableActions(expenseReport.policyID)) {
if (expenseReport.policyID && shouldRestrictUserBillableActions(expenseReport.policyID, userBillingGraceEndPeriods)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(expenseReport.policyID));
return;
}
Expand Down Expand Up @@ -11973,8 +11976,21 @@
}

function payMoneyRequest(params: PayMoneyRequestFunctionParams) {
const {paymentType, chatReport, iouReport, introSelected, iouReportCurrentNextStepDeprecated, currentUserAccountID, paymentPolicyID, full = true, activePolicy, policy, betas} = params;
if (chatReport.policyID && shouldRestrictUserBillableActions(chatReport.policyID)) {
const {
paymentType,
chatReport,
iouReport,
introSelected,
iouReportCurrentNextStepDeprecated,
currentUserAccountID,
paymentPolicyID,
userBillingGraceEndPeriods,
full = true,
activePolicy,
policy,
betas,
} = params;
if (chatReport.policyID && shouldRestrictUserBillableActions(chatReport.policyID, userBillingGraceEndPeriods)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(chatReport.policyID));
return;
}
Expand Down
Loading
Loading