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
2 changes: 1 addition & 1 deletion src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@
const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${moneyRequestReport?.reportID}`, {canBeMissing: true});
const getCanIOUBePaid = useCallback(
(onlyShowPayElsewhere = false, shouldCheckApprovedState = true) =>
canIOUBePaidAction(moneyRequestReport, chatReport, policy, transaction ? [transaction] : undefined, onlyShowPayElsewhere, undefined, undefined, shouldCheckApprovedState),

Check failure on line 355 in src/components/MoneyReportHeader.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Argument of type '({ amount: number; accountant?: Accountant | undefined; convertedAmount?: number | undefined; taxAmount?: number | undefined; taxCode?: string | undefined; taxValue?: string | undefined; ... 47 more ...; inserted?: string | undefined; } & OfflineFeedback<...>)[] | undefined' is not assignable to parameter of type 'string'.
[moneyRequestReport, chatReport, policy, transaction],
);

Expand Down Expand Up @@ -423,7 +423,7 @@
const shouldShowPayButton = isPaidAnimationRunning || canIOUBePaid || onlyShowPayElsewhere;

const shouldShowApproveButton = useMemo(
() => (canApproveIOU(moneyRequestReport, policy, transactions) && !hasOnlyPendingTransactions) || isApprovedAnimationRunning,

Check failure on line 426 in src/components/MoneyReportHeader.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Argument of type 'OnyxEntry<{ avatarUrl?: string | undefined; created?: string | undefined; chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly TRIP_ROOM: "tripRoom"; ... 6 more ...; readonly SYSTEM: "system"; }> | undefined; ... 55 more ...; nextStep?: ReportNextStep | un...' is not assignable to parameter of type 'number'.
[moneyRequestReport, policy, transactions, hasOnlyPendingTransactions, isApprovedAnimationRunning],
);

Expand Down Expand Up @@ -486,10 +486,10 @@
}
} else if (isInvoiceReport) {
startAnimation();
payInvoice(type, chatReport, moneyRequestReport, introSelected, payAsBusiness, existingB2BInvoiceReport, methodID, paymentMethod, activePolicy);

Check failure on line 489 in src/components/MoneyReportHeader.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Argument of type '{ avatarUrl?: string | undefined; created?: string | undefined; chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly TRIP_ROOM: "tripRoom"; ... 6 more ...; readonly SYSTEM: "system"; }> | undefined; ... 55 more ...; nextStep?: ReportNextStep | undefined; }...' is not assignable to parameter of type 'PaymentMethodType'.
} else {
startAnimation();
payMoneyRequest(type, chatReport, moneyRequestReport, introSelected, undefined, true, activePolicy);

Check failure on line 492 in src/components/MoneyReportHeader.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Argument of type 'string' is not assignable to parameter of type 'number'.
if (currentSearchQueryJSON && !isOffline) {
search({
searchKey: currentSearchKey,
Expand Down Expand Up @@ -903,7 +903,7 @@
if (!transaction?.transactionID) {
return;
}
markRejectViolationAsResolved(transaction?.transactionID, transactionThreadReport?.reportID);
markRejectViolationAsResolved(transaction?.transactionID, accountID, transactionThreadReport?.reportID);
}}
text={translate('iou.reject.markAsResolved')}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/MoneyRequestHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import HoldOrRejectEducationalModal from './HoldOrRejectEducationalModal';
import HoldSubmitterEducationalModal from './HoldSubmitterEducationalModal';
import Icon from './Icon';
import * as Expensicons from './Icon/Expensicons';

Check warning on line 62 in src/components/MoneyRequestHeader.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'./Icon/Expensicons' import is restricted from being used by a pattern. Direct imports from Icon/Expensicons are deprecated. Please use lazy loading hooks instead. Use `useMemoizedLazyExpensifyIcons` from @hooks/useLazyAsset. See docs/LAZY_ICONS_AND_ILLUSTRATIONS.md for details
import LoadingBar from './LoadingBar';
import type {MoneyRequestHeaderStatusBarProps} from './MoneyRequestHeaderStatusBar';
import MoneyRequestHeaderStatusBar from './MoneyRequestHeaderStatusBar';
Expand Down Expand Up @@ -215,7 +215,7 @@
if (!transaction?.transactionID) {
return;
}
markRejectViolationAsResolved(transaction?.transactionID, reportID);
markRejectViolationAsResolved(transaction?.transactionID, accountID, reportID);
}}
text={translate('iou.reject.markAsResolved')}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useSelectedTransactionsActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function useSelectedTransactionsActions({
if (!action?.childReportID) {
continue;
}
unholdRequest(transactionID, action?.childReportID);
unholdRequest(transactionID, action?.childReportID, session?.accountID ?? CONST.DEFAULT_NUMBER_ID);
}
clearSelectedTransactions(true);
},
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4908,7 +4908,7 @@ const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry<ReportAction>): vo

if (isOnHold) {
if (reportAction.childReportID) {
unholdRequest(transactionID, reportAction.childReportID);
unholdRequest(transactionID, reportAction.childReportID, currentUserAccountID);
} else {
Log.warn('Missing reportAction.childReportID during money request unhold');
}
Expand Down
107 changes: 61 additions & 46 deletions src/libs/actions/IOU.ts

Large diffs are not rendered by default.

17 changes: 12 additions & 5 deletions src/libs/actions/Search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ function deleteMoneyRequestOnSearch(hash: number, transactionIDList: string[]) {
}
}

function rejectMoneyRequestInBulk(hash: number, reportID: string, comment: string, transactionIDs: string[]) {
function rejectMoneyRequestInBulk(hash: number, reportID: string, comment: string, transactionIDs: string[], currentUserEmail: string) {
const {optimisticData, finallyData} = getOnyxLoadingData(hash);
const successData: OnyxUpdate[] = [];
const failureData: OnyxUpdate[] = [];
Expand All @@ -735,7 +735,7 @@ function rejectMoneyRequestInBulk(hash: number, reportID: string, comment: strin
}
> = {};
for (const transactionID of transactionIDs) {
const data = prepareRejectMoneyRequestData(transactionID, reportID, comment, undefined, true);
const data = prepareRejectMoneyRequestData(transactionID, reportID, comment, currentUserEmail, undefined, true);
if (data) {
optimisticData.push(...data.optimisticData);
successData.push(...data.successData);
Expand All @@ -754,7 +754,14 @@ function rejectMoneyRequestInBulk(hash: number, reportID: string, comment: strin
);
}

function rejectMoneyRequestsOnSearch(hash: number, selectedTransactions: SelectedTransactions, comment: string, allPolicies: OnyxCollection<Policy>, allReports: OnyxCollection<Report>) {
function rejectMoneyRequestsOnSearch(
hash: number,
selectedTransactions: SelectedTransactions,
comment: string,
allPolicies: OnyxCollection<Policy>,
allReports: OnyxCollection<Report>,
currentUserEmail: string,
) {
const transactionIDs = Object.keys(selectedTransactions);

const transactionsByReport = transactionIDs.reduce<Record<string, string[]>>((acc, transactionID) => {
Expand All @@ -777,12 +784,12 @@ function rejectMoneyRequestsOnSearch(hash: number, selectedTransactions: Selecte
const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`];
const isPolicyDelayedSubmissionEnabled = policy ? isDelayedSubmissionEnabled(policy) : false;
if (isPolicyDelayedSubmissionEnabled && areAllExpensesSelected) {
rejectMoneyRequestInBulk(hash, reportID, comment, allTransactionIDs);
rejectMoneyRequestInBulk(hash, reportID, comment, allTransactionIDs, currentUserEmail);
} else {
// Share a single destination ID across all rejections from the same source report
const sharedRejectedToReportID = generateReportID();
for (const transactionID of selectedTransactionIDs) {
rejectMoneyRequest(transactionID, reportID, comment, {sharedRejectedToReportID});
rejectMoneyRequest(transactionID, reportID, comment, currentUserEmail, {sharedRejectedToReportID});
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/pages/Search/SearchHoldReasonPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {useCallback, useEffect} from 'react';
import type {FormInputErrors, FormOnyxValues} from '@components/Form/types';
import {useSearchContext} from '@components/Search/SearchContext';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import {clearErrorFields, clearErrors} from '@libs/actions/FormActions';
Expand All @@ -24,12 +25,13 @@ function SearchHoldReasonPage({route}: SearchHoldReasonPageProps) {
const {backTo = '', reportID} = route.params ?? {};
const context = useSearchContext();
const [allTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {canBeMissing: true});
const {email, accountID} = useCurrentUserPersonalDetails();

const [allReportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS, {canBeMissing: true});
const onSubmit = useCallback(
({comment}: FormOnyxValues<typeof ONYXKEYS.FORMS.MONEY_REQUEST_HOLD_FORM>) => {
if (route.name === SCREENS.SEARCH.MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS) {
putTransactionsOnHold(context.selectedTransactionIDs, comment, reportID);
putTransactionsOnHold(context.selectedTransactionIDs, comment, reportID, email ?? '', accountID);
context.clearSelectedTransactions(true);
} else {
holdMoneyRequestOnSearch(context.currentSearchHash, Object.keys(context.selectedTransactions), comment, allTransactions, allReportActions);
Expand Down
4 changes: 3 additions & 1 deletion src/pages/Search/SearchRejectReasonPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {useCallback, useEffect} from 'react';
import type {FormInputErrors, FormOnyxValues} from '@components/Form/types';
import {useSearchContext} from '@components/Search/SearchContext';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useOnyx from '@hooks/useOnyx';
import {clearErrorFields, clearErrors} from '@libs/actions/FormActions';
import {rejectMoneyRequestsOnSearch} from '@libs/actions/Search';
Expand All @@ -14,9 +15,10 @@ function SearchRejectReasonPage() {
const context = useSearchContext();
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true});
const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true});
const {email} = useCurrentUserPersonalDetails();
const onSubmit = useCallback(
({comment}: FormOnyxValues<typeof ONYXKEYS.FORMS.MONEY_REQUEST_REJECT_FORM>) => {
rejectMoneyRequestsOnSearch(context.currentSearchHash, context.selectedTransactions, comment, allPolicies, allReports);
rejectMoneyRequestsOnSearch(context.currentSearchHash, context.selectedTransactions, comment, allPolicies, allReports, email ?? '');
context.clearSelectedTransactions();
Navigation.goBack();
},
Expand Down
2 changes: 1 addition & 1 deletion src/pages/TransactionDuplicate/Confirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function Confirmation() {
transactionsMergeParams.transactionThreadReportID = transactionThreadReportID;
}
closeReviewDuplicates();
IOU.mergeDuplicates(transactionsMergeParams);
IOU.mergeDuplicates({...transactionsMergeParams, currentUserEmail: currentUserPersonalDetails.email ?? ''});
}, [reportAction?.childReportID, transactionsMergeParams, closeReviewDuplicates]);

const resolveDuplicates = useCallback(() => {
Expand Down
4 changes: 3 additions & 1 deletion src/pages/iou/HoldReasonPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {useCallback, useEffect} from 'react';
import type {FormInputErrors, FormOnyxValues} from '@components/Form/types';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import {addErrorMessage} from '@libs/ErrorUtils';
Expand All @@ -26,6 +27,7 @@ function HoldReasonPage({route}: HoldReasonPageProps) {
const {transactionID, reportID, backTo} = route.params;

const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {canBeMissing: true});
const {email, accountID} = useCurrentUserPersonalDetails();

// We first check if the report is part of a policy - if not, then it's a personal request (1:1 request)
// For personal requests, we need to allow both users to put the request on hold
Expand All @@ -40,7 +42,7 @@ function HoldReasonPage({route}: HoldReasonPageProps) {
return;
}

putOnHold(transactionID, values.comment, reportID);
putOnHold(transactionID, values.comment, reportID, email ?? '', accountID);
Navigation.goBack(backTo);
};

Expand Down
4 changes: 3 additions & 1 deletion src/pages/iou/RejectReasonPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {useCallback, useEffect} from 'react';
import type {FormInputErrors, FormOnyxValues} from '@components/Form/types';
import {useSearchContext} from '@components/Search/SearchContext';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useLocalize from '@hooks/useLocalize';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
Expand All @@ -22,9 +23,10 @@ function RejectReasonPage({route}: RejectReasonPageProps) {

const {transactionID, reportID, backTo} = route.params;
const {removeTransaction} = useSearchContext();
const {email} = useCurrentUserPersonalDetails();

const onSubmit = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.MONEY_REQUEST_REJECT_FORM>) => {
const urlToNavigateBack = rejectMoneyRequest(transactionID, reportID, values.comment);
const urlToNavigateBack = rejectMoneyRequest(transactionID, reportID, values.comment, email ?? '');
removeTransaction(transactionID);
Navigation.dismissModal();
if (urlToNavigateBack) {
Expand Down
Loading