Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TS migration] Migrate 'MoneyRequestConfirmationList.js' component to TypeScript #34168

Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
cef767a
ref: started migratiing MoneyRequestConfirmationList
kubabutkiewicz Jan 9, 2024
d76e0df
ref: keep migrating
kubabutkiewicz Jan 9, 2024
e0dc2e9
ref: wip
kubabutkiewicz Jan 10, 2024
8946496
fix: wip
kubabutkiewicz Jan 10, 2024
64f3421
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 11, 2024
ef6ae5f
Update policyCategories type in MoneyRequestConfirmationList
kubabutkiewicz Jan 11, 2024
f00cfe9
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 15, 2024
441e437
fix: wip
kubabutkiewicz Jan 15, 2024
814715b
fix: wip
kubabutkiewicz Jan 15, 2024
e5921ce
fix: resolve comments
kubabutkiewicz Jan 17, 2024
1c2368b
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 17, 2024
5986deb
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 18, 2024
d851908
fix: typecheck
kubabutkiewicz Jan 18, 2024
72262ac
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 30, 2024
d4365b1
fix: typecheck
kubabutkiewicz Jan 30, 2024
2c030a3
fix: remove unnecessary default values
kubabutkiewicz Jan 30, 2024
5293f54
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 30, 2024
b037ab9
fix: typecheck
kubabutkiewicz Jan 30, 2024
90cc670
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 2, 2024
523302c
fix: sync with main
kubabutkiewicz Feb 2, 2024
b8d621e
fix: resolve comments
kubabutkiewicz Feb 2, 2024
c5eb136
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 5, 2024
2933d8a
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 6, 2024
5f3be37
fix: typecheck
kubabutkiewicz Feb 6, 2024
2f30432
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 8, 2024
1da3d09
fix: typecheck
kubabutkiewicz Feb 8, 2024
1e8cda2
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 9, 2024
7b514b3
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 9, 2024
bee66eb
fix: conflicts
kubabutkiewicz Feb 9, 2024
3a172d3
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 12, 2024
f69fce5
fix: typecheck
kubabutkiewicz Feb 12, 2024
67dd282
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 13, 2024
b93fa6b
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 14, 2024
68f4cf9
fix: typecheck
kubabutkiewicz Feb 14, 2024
d885513
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 15, 2024
d7708c1
fix: removed uncessesary condition
kubabutkiewicz Feb 15, 2024
d534c73
Merge branch 'main' into ts-migration/MoneyRequestConfirmationList/co…
kubabutkiewicz Feb 16, 2024
daf4759
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 20, 2024
d5aba80
fix: displaying thumbnail
kubabutkiewicz Feb 20, 2024
c5a4bb8
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 21, 2024
ef465f9
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 22, 2024
90a7ad9
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 26, 2024
479cf7a
fix: typecheck
kubabutkiewicz Feb 26, 2024
f1915bc
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 27, 2024
f17da9e
fix: typecheck
kubabutkiewicz Feb 27, 2024
ad6eff9
fix: linter
kubabutkiewicz Feb 27, 2024
b953adc
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 27, 2024
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
3 changes: 2 additions & 1 deletion src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,9 @@ type OnyxValues = {
[ONYXKEYS.COLLECTION.DOWNLOAD]: OnyxTypes.Download;
[ONYXKEYS.COLLECTION.POLICY]: OnyxTypes.Policy;
[ONYXKEYS.COLLECTION.POLICY_DRAFTS]: OnyxTypes.Policy;
[ONYXKEYS.COLLECTION.POLICY_CATEGORIES]: OnyxTypes.PolicyCategory;
[ONYXKEYS.COLLECTION.POLICY_CATEGORIES]: OnyxTypes.PolicyCategories;
[ONYXKEYS.COLLECTION.POLICY_TAGS]: OnyxTypes.PolicyTags;
[ONYXKEYS.COLLECTION.POLICY_TAX_RATE]: OnyxTypes.PolicyTaxRate;
[ONYXKEYS.COLLECTION.POLICY_MEMBERS]: OnyxTypes.PolicyMembers;
[ONYXKEYS.COLLECTION.POLICY_MEMBERS_DRAFTS]: OnyxTypes.PolicyMember;
[ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_CATEGORIES]: OnyxTypes.RecentlyUsedCategories;
Expand Down
2 changes: 1 addition & 1 deletion src/components/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ type MenuItemProps = (IconProps | AvatarProps | NoIcon) & {
shouldBlockSelection?: boolean;

/** Whether should render title as HTML or as Text */
shouldParseTitle?: false;
shouldParseTitle?: boolean;

/** Should check anonymous user in onPress function */
shouldCheckActionAllowedOnPress?: boolean;
Expand Down
841 changes: 0 additions & 841 deletions src/components/MoneyRequestConfirmationList.js

This file was deleted.

828 changes: 828 additions & 0 deletions src/components/MoneyRequestConfirmationList.tsx

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/libs/ReceiptUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Str from 'expensify-common/lib/str';
import type {ImageSourcePropType} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import ReceiptDoc from '@assets/images/receipt-doc.png';
import ReceiptGeneric from '@assets/images/receipt-generic.png';
import ReceiptHTML from '@assets/images/receipt-html.png';
Expand Down Expand Up @@ -28,7 +29,7 @@ type FileNameAndExtension = {
* @param receiptPath
* @param receiptFileName
*/
function getThumbnailAndImageURIs(transaction: Transaction, receiptPath: string | null = null, receiptFileName: string | null = null): ThumbnailAndImageURI {
function getThumbnailAndImageURIs(transaction: OnyxEntry<Transaction>, receiptPath: string | null = null, receiptFileName: string | null = null): ThumbnailAndImageURI {
// URI to image, i.e. blob:new.expensify.com/9ef3a018-4067-47c6-b29f-5f1bd35f213d or expensify.com/receipts/w_e616108497ef940b7210ec6beb5a462d01a878f4.jpg
const path = transaction?.receipt?.source ?? receiptPath ?? '';
// filename of uploaded image or last part of remote URI
Expand All @@ -39,7 +40,7 @@ function getThumbnailAndImageURIs(transaction: Transaction, receiptPath: string

if (!Object.hasOwn(transaction?.pendingFields ?? {}, 'waypoints')) {
if (hasEReceipt) {
return {thumbnail: null, image: ROUTES.ERECEIPT.getRoute(transaction.transactionID), transaction};
return {thumbnail: null, image: ROUTES.ERECEIPT.getRoute(transaction?.transactionID), transaction};
}

// For local files, we won't have a thumbnail yet
Expand Down
3 changes: 2 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type Participant = {
searchText: string;
selected: boolean;
text: string;
descriptiveText?: string;
};

type SpendBreakdown = {
Expand Down Expand Up @@ -4536,4 +4537,4 @@ export {
shouldDisableThread,
};

export type {ExpenseOriginalMessage, OptionData, OptimisticChatReport, OptimisticCreatedReportAction};
export type {ExpenseOriginalMessage, OptionData, OptimisticChatReport, OptimisticCreatedReportAction, Participant};
19 changes: 10 additions & 9 deletions src/libs/TransactionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,24 @@ function hasReceipt(transaction: Transaction | undefined | null): boolean {
return !!transaction?.receipt?.state || hasEReceipt(transaction);
}

function isMerchantMissing(transaction: Transaction) {
const isMerchantEmpty = transaction.merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT || transaction.merchant === '';
function isMerchantMissing(transaction: OnyxEntry<Transaction>) {
const isMerchantEmpty = transaction?.merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT || transaction?.merchant === '';

const isModifiedMerchantEmpty = !transaction.modifiedMerchant || transaction.modifiedMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT || transaction.modifiedMerchant === '';
const isModifiedMerchantEmpty =
!transaction?.modifiedMerchant || transaction?.modifiedMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT || transaction?.modifiedMerchant === '';

return isMerchantEmpty && isModifiedMerchantEmpty;
}

function isAmountMissing(transaction: Transaction) {
return transaction.amount === 0 && (!transaction.modifiedAmount || transaction.modifiedAmount === 0);
function isAmountMissing(transaction: OnyxEntry<Transaction>) {
return transaction?.amount === 0 && (!transaction?.modifiedAmount || transaction?.modifiedAmount === 0);
}

function isCreatedMissing(transaction: Transaction) {
return transaction.created === '' && (!transaction.created || transaction.modifiedCreated === '');
function isCreatedMissing(transaction: OnyxEntry<Transaction>) {
return transaction?.created === '' && (!transaction?.created || transaction?.modifiedCreated === '');
}

function areRequiredFieldsEmpty(transaction: Transaction): boolean {
function areRequiredFieldsEmpty(transaction: OnyxEntry<Transaction>): boolean {
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transaction?.reportID}`] ?? null;
const isFromExpenseReport = parentReport?.type === CONST.REPORT.TYPE.EXPENSE;
return (isFromExpenseReport && isMerchantMissing(transaction)) || isAmountMissing(transaction) || isCreatedMissing(transaction);
Expand Down Expand Up @@ -434,7 +435,7 @@ function hasMissingSmartscanFields(transaction: OnyxEntry<Transaction>): boolean
/**
* Check if the transaction has a defined route
*/
function hasRoute(transaction: Transaction): boolean {
function hasRoute(transaction: OnyxEntry<Transaction>): boolean {
return !!transaction?.routes?.route0?.geometry?.coordinates;
}

Expand Down
17 changes: 16 additions & 1 deletion src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ type Rate = {
currency: string;
};

type MileageRate = {
unit: Unit;
rate: number;
currency: string;
};

type CustomUnit = {
customUnitID?: string;
name?: string;
Expand Down Expand Up @@ -82,8 +88,17 @@ type Policy = {

/** The employee list of the policy */
employeeList?: [];

/** Whether tax tracking enabled for policy */
isTaxTrackingEnabled?: boolean;

disabledFields?: Record<string, boolean>;

requiresCategory?: boolean;

requiresTag?: boolean;
kubabutkiewicz marked this conversation as resolved.
Show resolved Hide resolved
};

export default Policy;

export type {Unit};
export type {Unit, MileageRate};
1 change: 1 addition & 0 deletions src/types/onyx/PolicyTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type PolicyTag = {
/** "General Ledger code" that corresponds to this tag in an accounting system. Similar to an ID. */
// eslint-disable-next-line @typescript-eslint/naming-convention
'GL Code': string;
tags: PolicyTags;
};

type PolicyTags = Record<string, PolicyTag>;
Expand Down
4 changes: 4 additions & 0 deletions src/types/onyx/PolicyTaxRates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ type PolicyTaxRate = {

/** Whether the tax is disabled */
isDisabled?: boolean;

defaultExternalID: string;

taxes: PolicyTaxRates;
kubabutkiewicz marked this conversation as resolved.
Show resolved Hide resolved
};

type PolicyTaxRates = Record<string, PolicyTaxRate>;
Expand Down
12 changes: 12 additions & 0 deletions src/types/onyx/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import type CONST from '@src/CONST';
import type * as OnyxCommon from './OnyxCommon';
import type RecentWaypoint from './RecentWaypoint';

type TaxRate = {
text: string;
keyForList: string;
data: {
value: string;
};
modifiedName?: string;
};

type Waypoint = {
/** The name associated with the address of the waypoint */
name?: string;
Expand All @@ -18,6 +27,7 @@ type Waypoint = {
};

type WaypointCollection = Record<string, RecentWaypoint | Waypoint>;

type Comment = {
comment?: string;
waypoints?: WaypointCollection;
Expand Down Expand Up @@ -94,6 +104,8 @@ type Transaction = {
/** If the transaction was made in a foreign currency, we send the original amount and currency */
originalAmount?: number;
originalCurrency?: string;
taxAmount?: number;
taxRate?: TaxRate;
};

export default Transaction;
Expand Down
4 changes: 4 additions & 0 deletions src/types/onyx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import type {PolicyMembers} from './PolicyMember';
import type PolicyMember from './PolicyMember';
import type PolicyReportField from './PolicyReportField';
import type {PolicyTag, PolicyTags} from './PolicyTag';
import type {PolicyTaxRates} from './PolicyTaxRates';
import type PolicyTaxRate from './PolicyTaxRates';
import type PrivatePersonalDetails from './PrivatePersonalDetails';
import type RecentlyUsedCategories from './RecentlyUsedCategories';
import type RecentlyUsedReportFields from './RecentlyUsedReportFields';
Expand Down Expand Up @@ -139,4 +141,6 @@ export type {
ReportUserIsTyping,
PolicyReportField,
RecentlyUsedReportFields,
PolicyTaxRate,
PolicyTaxRates,
};
Loading