Skip to content
Closed
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
5 changes: 5 additions & 0 deletions src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@

let allTransactions: OnyxCollection<Transaction> = {};

Onyx.connect({

Check warning on line 116 in src/libs/TransactionUtils/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,

Check warning on line 117 in src/libs/TransactionUtils/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
waitForCollectionCallback: true,
callback: (value) => {
if (!value) {
Expand All @@ -125,8 +125,8 @@
});

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

Check warning on line 128 in src/libs/TransactionUtils/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,

Check warning on line 129 in src/libs/TransactionUtils/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
waitForCollectionCallback: true,
callback: (value) => {
allReports = value;
Expand All @@ -134,16 +134,16 @@
});

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

Check warning on line 137 in src/libs/TransactionUtils/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,

Check warning on line 138 in src/libs/TransactionUtils/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
waitForCollectionCallback: true,
callback: (value) => (allTransactionViolations = value),
});

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

Check warning on line 145 in src/libs/TransactionUtils/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,

Check warning on line 146 in src/libs/TransactionUtils/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
callback: (val) => {
currentUserEmail = val?.email ?? '';
currentUserAccountID = val?.accountID ?? CONST.DEFAULT_NUMBER_ID;
Expand Down Expand Up @@ -211,6 +211,10 @@
return type === CONST.TRANSACTION.TYPE.CUSTOM_UNIT && customUnitName === CONST.CUSTOM_UNITS.NAME_PER_DIEM_INTERNATIONAL;
}

function isCorporateCardTransaction(transaction: OnyxEntry<Transaction>): boolean {
return isCardTransaction(transaction) && transaction?.comment?.liabilityType === CONST.TRANSACTION.LIABILITY_TYPE.RESTRICT;
}

function getRequestType(transaction: OnyxEntry<Transaction>, isManualDistanceEnabled?: boolean): IOURequestType {
if (isManualDistanceEnabled) {
if (isManualDistanceRequest(transaction)) {
Expand Down Expand Up @@ -2065,6 +2069,7 @@
isUnreportedAndHasInvalidDistanceRateTransaction,
getTransactionViolationsOfTransaction,
isExpenseSplit,
isCorporateCardTransaction,
isExpenseUnreported,
};

Expand Down
9 changes: 7 additions & 2 deletions src/pages/iou/request/MoneyRequestParticipantsSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ type MoneyRequestParticipantsSelectorProps = {
/** Whether this is a per diem expense request */
isPerDiemRequest?: boolean;

/** Whether this is a corporate card transaction */
isCorporateCardTransaction?: boolean;

/** Reference to the outer element */
ref?: Ref<InputFocusRef>;
};
Expand All @@ -98,6 +101,7 @@ function MoneyRequestParticipantsSelector({
iouType,
action,
isPerDiemRequest = false,
isCorporateCardTransaction = false,
ref,
}: MoneyRequestParticipantsSelectorProps) {
const {translate} = useLocalize();
Expand Down Expand Up @@ -173,8 +177,8 @@ function MoneyRequestParticipantsSelector({
// Sharing with an accountant involves inviting them to the workspace and that requires admin access.
excludeNonAdminWorkspaces: action === CONST.IOU.ACTION.SHARE,

// Per diem expenses should only be submitted to workspaces, not individual users
includeP2P: !isCategorizeOrShareAction && !isPerDiemRequest,
// Per diem expenses and corporate card transactions should only be submitted to workspaces, not individual users
includeP2P: !isCategorizeOrShareAction && !isPerDiemRequest && !isCorporateCardTransaction,
includeInvoiceRooms: iouType === CONST.IOU.TYPE.INVOICE,
action,
shouldSeparateSelfDMChat: iouType !== CONST.IOU.TYPE.INVOICE,
Expand Down Expand Up @@ -205,6 +209,7 @@ function MoneyRequestParticipantsSelector({
participants,
isPerDiemRequest,
canShowManagerMcTest,
isCorporateCardTransaction,
]);

const chatOptions = useMemo(() => {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/iou/request/step/IOURequestStepParticipants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Performance from '@libs/Performance';
import {isPaidGroupPolicy} from '@libs/PolicyUtils';
import {findSelfDMReportID, generateReportID, isInvoiceRoomWithID} from '@libs/ReportUtils';
import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils';
import {getRequestType, isPerDiemRequest} from '@libs/TransactionUtils';
import {getRequestType, isCorporateCardTransaction, isPerDiemRequest} from '@libs/TransactionUtils';
import MoneyRequestParticipantsSelector from '@pages/iou/request/MoneyRequestParticipantsSelector';
import {
navigateToStartStepIfScanFileCannotBeRead,
Expand Down Expand Up @@ -353,6 +353,7 @@ function IOURequestStepParticipants({
iouType={iouType}
action={action}
isPerDiemRequest={isPerDiemRequest(initialTransaction)}
isCorporateCardTransaction={isCorporateCardTransaction(initialTransaction)}
/>
)}
</StepScreenWrapper>
Expand Down
Loading