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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {COPYABLE_TEXT_DATA_SET} from '@libs/SelectionScraper';
import {isDeletedTransaction} from '@libs/TransactionUtils';

import CONST from '@src/CONST';
import type {Report} from '@src/types/onyx';

import type {StyleProp, ViewStyle} from 'react-native';

Expand All @@ -19,27 +20,21 @@ import type {StyleProp, ViewStyle} from 'react-native';
import React from 'react';
import {View} from 'react-native';

import type {ExpenseReportListItemType, TransactionListItemType, TransactionReportGroupListItemType} from './types';
import type {ExpenseReportListItemType} from './types';

import UserInfoCellsWithArrow from './UserInfoCellsWithArrow';

function UserInfoAndActionButtonRow({
item,
shouldShowUserInfo,
containerStyles,
stateNum,
statusNum,
isSelected,
shouldAllowStatusTextSelection = false,
}: {
item: TransactionReportGroupListItemType | TransactionListItemType | ExpenseReportListItemType;
type UserInfoAndActionButtonRowProps = {
item: Pick<ExpenseReportListItemType, 'from' | 'to' | 'formattedFrom'> & Partial<Pick<Report, 'reportID'>>;
shouldShowUserInfo: boolean;
containerStyles?: StyleProp<ViewStyle>;
stateNum: ExpenseReportListItemType['stateNum'];
statusNum: ExpenseReportListItemType['statusNum'];
isSelected?: boolean;
shouldAllowStatusTextSelection?: boolean;
}) {
};

function UserInfoAndActionButtonRow({item, shouldShowUserInfo, containerStyles, stateNum, statusNum, isSelected, shouldAllowStatusTextSelection = false}: UserInfoAndActionButtonRowProps) {
const styles = useThemeStyles();
const theme = useTheme();
const {translate} = useLocalize();
Expand Down
8 changes: 2 additions & 6 deletions src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ import {isEmptyObject} from '@src/types/utils/EmptyObject';
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';

import type {ComponentRef} from 'react';
import type {TupleToUnion} from 'type-fest';

import {useIsFocused} from '@react-navigation/native';
import {Str} from 'expensify-common';
Expand All @@ -81,7 +80,6 @@ import getStepToOpenFromRouteParams from './USD/utils/getStepToOpenFromRoutePara
import VerifiedBankAccountFlowEntryPoint from './VerifiedBankAccountFlowEntryPoint';

type ReimbursementAccountPageProps = WithPolicyOnyxProps & PlatformStackScreenProps<ReimbursementAccountNavigatorParamList, typeof SCREENS.REIMBURSEMENT_ACCOUNT_ROOT>;
type CurrencyType = TupleToUnion<typeof CONST.DIRECT_REIMBURSEMENT_CURRENCIES>;

const OFFLINE_ACCESSIBLE_STEPS = [
CONST.BANK_ACCOUNT.STEP.COUNTRY,
Expand Down Expand Up @@ -111,7 +109,7 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen
const subStepParam = route.params?.subStep;
const backTo = route.params?.backTo;
const isChangingBankAccount = !!route.params?.isChangingBankAccount;
const isComingFromExpensifyCard = (backTo as string)?.includes(CONST.EXPENSIFY_CARD.ROUTE as string);
const isComingFromExpensifyCard = backTo?.includes(CONST.EXPENSIFY_CARD.ROUTE);
const styles = useThemeStyles();
const {translate} = useLocalize();
const {isOffline} = useNetwork();
Expand Down Expand Up @@ -151,9 +149,7 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen
}
const isNonUSDWorkspace = !!policyCurrency && policyCurrency !== CONST.CURRENCY.USD;
const hasUnsupportedCurrency =
isComingFromExpensifyCard && isNonUSDWorkspace
? !isCurrencySupportedForECards(policyCurrency)
: policyCurrency && !isCurrencySupportedForGlobalReimbursement(policyCurrency as CurrencyType);
isComingFromExpensifyCard && isNonUSDWorkspace ? !isCurrencySupportedForECards(policyCurrency) : policyCurrency && !isCurrencySupportedForGlobalReimbursement(policyCurrency);

const nonUSDCountryDraftValue = reimbursementAccountDraft?.country ?? '';
let workspaceRoute = '';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type {FormOnyxValues} from '@components/Form/types';
import FullNameStep from '@components/SubStepForms/FullNameStep';

import useLocalize from '@hooks/useLocalize';
Expand All @@ -22,8 +21,8 @@ function LegalNameUBO({onNext, onMove, isEditing, beneficialOwnerBeingModifiedID

const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT);

const firstNameInputID = `${BENEFICIAL_OWNER_PREFIX}_${beneficialOwnerBeingModifiedID}_${FIRST_NAME}` as keyof FormOnyxValues;
const lastNameInputID = `${BENEFICIAL_OWNER_PREFIX}_${beneficialOwnerBeingModifiedID}_${LAST_NAME}` as keyof FormOnyxValues;
const firstNameInputID = `${BENEFICIAL_OWNER_PREFIX}_${beneficialOwnerBeingModifiedID}_${FIRST_NAME}` as const;
const lastNameInputID = `${BENEFICIAL_OWNER_PREFIX}_${beneficialOwnerBeingModifiedID}_${LAST_NAME}` as const;
const stepFields = [firstNameInputID, lastNameInputID];
const defaultValues = {
firstName: SafeString(reimbursementAccountDraft?.[firstNameInputID]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@ import {getFieldRequiredErrors} from '@libs/ValidationUtils';
import getSubStepValues from '@pages/ReimbursementAccount/utils/getSubStepValues';

import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
import INPUT_IDS from '@src/types/form/ReimbursementAccountForm';

import type {CONST as COMMON_CONST} from 'expensify-common';

import React, {useCallback, useMemo} from 'react';

type States = keyof typeof COMMON_CONST.STATES;

const BUSINESS_INFO_STEP_KEYS = INPUT_IDS.BUSINESS_INFO_STEP;
const BUSINESS_INFO_STEP_INDEXES = CONST.REIMBURSEMENT_ACCOUNT.SUBSTEP_INDEX.BUSINESS_INFO;

Expand Down Expand Up @@ -62,6 +57,8 @@ function ConfirmationBusiness({onNext, onMove}: SubPageProps) {
);

const values = useMemo(() => getSubStepValues(BUSINESS_INFO_STEP_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]);
const incorporationType = values[BUSINESS_INFO_STEP_KEYS.INCORPORATION_TYPE];
const incorporationState = values[BUSINESS_INFO_STEP_KEYS.INCORPORATION_STATE];

const defaultCheckboxState = reimbursementAccountDraft?.[BUSINESS_INFO_STEP_KEYS.HAS_NO_CONNECTION_TO_CANNABIS] ?? false;

Expand Down Expand Up @@ -108,11 +105,7 @@ function ConfirmationBusiness({onNext, onMove}: SubPageProps) {
onPress={() => {
onMove(BUSINESS_INFO_STEP_INDEXES.COMPANY_TYPE);
}}
value={
values[BUSINESS_INFO_STEP_KEYS.INCORPORATION_TYPE]
? translate(`businessInfoStep.incorporationType.${values[BUSINESS_INFO_STEP_KEYS.INCORPORATION_TYPE]}` as TranslationPaths)
: undefined
}
value={incorporationType ? translate(`businessInfoStep.incorporationType.${incorporationType}`) : undefined}
/>
<MenuItemField
name={translate('businessInfoStep.incorporationDate')}
Expand All @@ -126,7 +119,7 @@ function ConfirmationBusiness({onNext, onMove}: SubPageProps) {
onPress={() => {
onMove(BUSINESS_INFO_STEP_INDEXES.INCORPORATION_STATE);
}}
value={values[BUSINESS_INFO_STEP_KEYS.INCORPORATION_STATE] ? translate(`allStates.${values[BUSINESS_INFO_STEP_KEYS.INCORPORATION_STATE] as States}.stateName`) : undefined}
value={incorporationState ? translate(`allStates.${incorporationState}.stateName`) : undefined}
/>
<MenuItemField
name={translate('companyStep.industryClassificationCode')}
Expand Down
22 changes: 10 additions & 12 deletions src/pages/Search/SearchMoneyRequestReportPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import type {RightModalNavigatorParamList} from '@libs/Navigation/types';
import {getIOUActionForTransactionID, getReportAction} from '@libs/ReportActionsUtils';
import {getReportName} from '@libs/ReportNameUtils';
import {isMoneyRequestReportPendingDeletion, isValidReportIDFromPath} from '@libs/ReportUtils';
import {isTransactionEntry} from '@libs/SearchUIUtils';
import {cancelAllSendMessageSpans} from '@libs/telemetry/sendMessageSpans';
import {doesDeleteNavigateBackUrlIncludeDuplicatesReview, getParentReportActionDeletionStatus, hasLoadedReportActions, isThreadReportDeleted} from '@libs/TransactionNavigationUtils';

Expand All @@ -47,7 +48,6 @@ import {clearDeleteTransactionNavigateBackUrl, createTransactionThreadReport, op
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import SCREENS from '@src/SCREENS';
import type {Transaction, TransactionViolations} from '@src/types/onyx';

import {PortalHost} from '@gorhom/portal';
import {useIsFocused} from '@react-navigation/native';
Expand Down Expand Up @@ -170,22 +170,20 @@ function SearchMoneyRequestReportPage({route}: SearchMoneyRequestPageProps) {
return {snapshotTransaction: undefined, snapshotViolations: undefined};
}

const snapshotData = snapshot.data as Record<string, unknown>;
const transactionKey = Object.keys(snapshotData).find((key) => {
if (!key.startsWith(ONYXKEYS.COLLECTION.TRANSACTION)) {
return false;
}
const candidate = snapshotData[key];
return typeof candidate === 'object' && candidate !== null && 'reportID' in candidate && candidate.reportID === reportIDFromRoute;
});
const snapshotData = snapshot.data;
const transactionKey = Object.keys(snapshotData)
.filter(isTransactionEntry)
.find((key) => {
const candidate = snapshotData[key];
return typeof candidate === 'object' && candidate !== null && 'reportID' in candidate && candidate.reportID === reportIDFromRoute;
});
if (!transactionKey) {
return {snapshotTransaction: undefined, snapshotViolations: undefined};
}

const transaction = snapshotData[transactionKey] as Transaction;
const transaction = snapshotData[transactionKey];

const violationKey = `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`;
const violations = snapshotData[violationKey] as TransactionViolations | undefined;
const violations = snapshotData[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`];

return {snapshotTransaction: transaction, snapshotViolations: violations};
}, [snapshot?.data, allReportTransactions, reportIDFromRoute]);
Expand Down
7 changes: 3 additions & 4 deletions src/pages/TransactionDuplicate/DuplicateTransactionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback';
import {usePersonalDetails} from '@components/OnyxListItemProvider';
import {PressableWithFeedback} from '@components/Pressable';
import RadioButton from '@components/RadioButton';
import type {ExpenseReportListItemType, TransactionListItemType} from '@components/Search/SearchList/ListItem/types';
import UserInfoAndActionButtonRow from '@components/Search/SearchList/ListItem/UserInfoAndActionButtonRow';
import TransactionItemRow from '@components/TransactionItemRow';

Expand Down Expand Up @@ -55,12 +54,12 @@ function DuplicateTransactionItem({transaction, isLastItem, isSelected, shouldSh
});
const ownerPersonalDetails = report?.ownerAccountID ? personalDetails?.[report.ownerAccountID] : undefined;
const reportStatusItem = ownerPersonalDetails
? ({
? {
...report,
from: ownerPersonalDetails,
to: ownerPersonalDetails,
formattedFrom: ownerPersonalDetails.displayName ?? '',
} as ExpenseReportListItemType)
}
: undefined;

const handlePreviewPress = () => {
Expand Down Expand Up @@ -120,7 +119,7 @@ function DuplicateTransactionItem({transaction, isLastItem, isSelected, shouldSh
/>
)}
<TransactionItemRow
transactionItem={transaction as TransactionListItemType}
transactionItem={transaction}
report={report}
policy={policy}
shouldUseNarrowLayout
Expand Down
7 changes: 5 additions & 2 deletions src/types/form/ReimbursementAccountForm.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type CONST from '@src/CONST';
import type {Country} from '@src/CONST';
import type {FileObject} from '@src/types/utils/Attachment';
import type DeepValueOf from '@src/types/utils/DeepValueOf';

import type {CONST as COMMON_CONST} from 'expensify-common';

import type Form from './Form';

const INPUT_IDS = {
Expand Down Expand Up @@ -205,9 +208,9 @@ type CompanyStepProps = {
[INPUT_IDS.BUSINESS_INFO_STEP.COMPANY_PHONE]: string;
[INPUT_IDS.BUSINESS_INFO_STEP.COMPANY_WEBSITE]: string;
[INPUT_IDS.BUSINESS_INFO_STEP.COMPANY_TAX_ID]: string;
[INPUT_IDS.BUSINESS_INFO_STEP.INCORPORATION_TYPE]: string;
[INPUT_IDS.BUSINESS_INFO_STEP.INCORPORATION_TYPE]: keyof typeof CONST.INCORPORATION_TYPES | '';
[INPUT_IDS.BUSINESS_INFO_STEP.INCORPORATION_DATE]: string;
[INPUT_IDS.BUSINESS_INFO_STEP.INCORPORATION_STATE]: string;
[INPUT_IDS.BUSINESS_INFO_STEP.INCORPORATION_STATE]: keyof typeof COMMON_CONST.STATES | '';
[INPUT_IDS.BUSINESS_INFO_STEP.INCORPORATION_CODE]: string;
[INPUT_IDS.BUSINESS_INFO_STEP.HAS_NO_CONNECTION_TO_CANNABIS]: boolean;
};
Expand Down
Loading
Loading