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
9 changes: 5 additions & 4 deletions config/eslint/eslint.seatbelt.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
"../../src/components/MoneyRequestConfirmationList/sections/AmountField.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/MoneyRequestConfirmationList/sections/AttendeeField.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/MoneyRequestConfirmationList/sections/TaxFields.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/MoneyRequestConfirmationList/sections/selectors.ts" "@typescript-eslint/no-unsafe-type-assertion" 7
"../../src/components/MoneyRequestConfirmationList/sections/selectors.ts" "@typescript-eslint/no-unsafe-type-assertion" 3
"../../src/components/MoneyRequestConfirmationListFooter/ConfirmationReceiptThumbnail.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/MoneyRequestConfirmationListFooter/hooks/useReceiptThumbnailSource.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/MoneyRequestConfirmationListFooter/sections/DistanceMapSection.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
Expand Down Expand Up @@ -679,7 +679,7 @@
"../../src/libs/Navigation/AppNavigator/routerExtensions/addRootHistoryRouterExtension.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/libs/Navigation/AppNavigator/routerExtensions/addRootHistoryRouterExtensionUtils.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/libs/Navigation/DebugTabNavigator.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/libs/Navigation/Navigation.ts" "@typescript-eslint/no-unsafe-type-assertion" 11
"../../src/libs/Navigation/Navigation.ts" "@typescript-eslint/no-unsafe-type-assertion" 10
"../../src/libs/Navigation/Navigation.ts" "no-restricted-imports" 1
"../../src/libs/Navigation/OnyxTabNavigator.tsx" "@typescript-eslint/no-unsafe-type-assertion" 4
"../../src/libs/Navigation/PlatformStackNavigation/ScreenLayout.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
Expand Down Expand Up @@ -771,7 +771,8 @@
"../../src/libs/ReportUtils.ts" "rulesdir/no-onyx-connect" 16
"../../src/libs/SearchAutocompleteUtils.ts" "@typescript-eslint/no-unsafe-type-assertion" 4
"../../src/libs/SearchQueryUtils.ts" "@typescript-eslint/no-unsafe-type-assertion" 73
"../../src/libs/SearchUIUtils.ts" "@typescript-eslint/no-unsafe-type-assertion" 71
"../../src/libs/SearchUIUtils.ts" "@typescript-eslint/no-deprecated/getSearchReportName" 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this new entry?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes — this entry came in via the merge commit that brought our branch up to date with main. A recently merged PR (f1c9bc6c12a) introduced a call to the (deprecated) getSearchReportName function in SearchUIUtils.ts, so the seatbelt needs to track it. This PR isn't the right place to fix a no-deprecated violation — but removing the entry would cause the lint check to fail since the actual call is still there.

"../../src/libs/SearchUIUtils.ts" "@typescript-eslint/no-unsafe-type-assertion" 69
"../../src/libs/SelectionScraper/index.ts" "@typescript-eslint/no-unsafe-type-assertion" 4
"../../src/libs/SidebarUtils.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/libs/Sound/index.native.ts" "@typescript-eslint/no-unsafe-type-assertion" 4
Expand Down Expand Up @@ -1843,7 +1844,7 @@
"../../tests/unit/Search/SearchListRenderCountTest.tsx" "@typescript-eslint/no-unsafe-type-assertion" 2
"../../tests/unit/Search/SearchQueryUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 9
"../../tests/unit/Search/SearchSingleSelectionPickerTest.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../tests/unit/Search/SearchUIUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 135
"../../tests/unit/Search/SearchUIUtilsTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 133
"../../tests/unit/Search/buildCardFilterDataTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 22
"../../tests/unit/Search/buildSubstitutionsMapTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 3
"../../tests/unit/Search/getSpendOverTimeStateTest.ts" "@typescript-eslint/no-unsafe-type-assertion" 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ type InvoiceSenderFieldProps = {
/** The report ID */
reportID: string;

/** The transaction */
transaction: OnyxEntry<OnyxTypes.Transaction>;
/** The transaction (only the fields this field reads) */
transaction: OnyxEntry<Pick<OnyxTypes.Transaction, 'isFromGlobalCreate' | 'transactionID'>>;
};

const senderWorkspaceSelector = (policy: OnyxEntry<OnyxTypes.Policy>) => (policy ? {id: policy.id, name: policy.name, avatarURL: policy.avatarURL} : undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const createTagDisplaySelector = (tagIndex: number) => (t: OnyxEntry<Transaction
if (!t) {
return undefined;
}
return getTagForDisplay({tag: t.tag} as OnyxEntry<Transaction>, tagIndex);
return getTagForDisplay({tag: t.tag}, tagIndex);
};

// --- CategoryField ---
Expand Down Expand Up @@ -200,7 +200,7 @@ const taxSliceSelector = (t: OnyxEntry<Transaction>): TaxSlice | undefined => {

type DerivedFlagsSlice = Pick<Transaction, 'modifiedCurrency' | 'currency' | 'iouRequestType' | 'reportID' | 'managedCard'>;

const derivedFlagsSliceSelector = (t: OnyxEntry<Transaction>): OnyxEntry<Transaction> => {
const derivedFlagsSliceSelector = (t: OnyxEntry<Transaction>): OnyxEntry<DerivedFlagsSlice> => {
if (!t) {
return undefined;
}
Expand All @@ -211,34 +211,34 @@ const derivedFlagsSliceSelector = (t: OnyxEntry<Transaction>): OnyxEntry<Transac
reportID: t.reportID,
managedCard: t.managedCard,
};
return slice as Transaction;
return slice;
};

// --- ConfirmationFieldList: useFooterTagVisibility ---

type TagSlice = Pick<Transaction, 'tag'>;

const tagSliceSelector = (t: OnyxEntry<Transaction>): OnyxEntry<Transaction> => {
const tagSliceSelector = (t: OnyxEntry<Transaction>): OnyxEntry<TagSlice> => {
if (!t) {
return undefined;
}
const slice: TagSlice = {tag: t.tag};
return slice as Transaction;
return slice;
};

// --- InvoiceSenderSection ---

type InvoiceSenderSlice = Pick<Transaction, 'isFromGlobalCreate' | 'transactionID'>;

const invoiceSenderSliceSelector = (t: OnyxEntry<Transaction>): OnyxEntry<Transaction> => {
const invoiceSenderSliceSelector = (t: OnyxEntry<Transaction>): OnyxEntry<InvoiceSenderSlice> => {
if (!t) {
return undefined;
}
const slice: InvoiceSenderSlice = {
isFromGlobalCreate: t.isFromGlobalCreate,
transactionID: t.transactionID,
};
return slice as Transaction;
return slice;
};

// --- DistanceMapSection ---
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Navigation/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ function removePreInsertedFullscreenIfNeeded() {
const originalTabRoute = getPreInsertedOriginalTabRoute();
if (originalTabRoute) {
clearPreInsertedOriginalTabRoute();
const originalTabState = originalTabRoute.state as NavigationState | undefined;
const originalTabState = originalTabRoute.state;
const originalFocusedTabIndex = originalTabState?.index ?? 0;
const originalTabName = originalTabState?.routes?.[originalFocusedTabIndex]?.name;
if (originalTabName) {
Expand Down
18 changes: 13 additions & 5 deletions src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5355,18 +5355,26 @@ function getWithdrawalStatusDisplayText(value: SearchWithdrawalStatus | undefine
.join(', ');
}

/**
* A `PolicyCategoriesLookup` can either be a single policy's categories or an Onyx collection of
* many policies' categories keyed by `policy_categories_<policyID>`. A collection is the only
* variant whose keys start with that prefix, so we use that to discriminate the union.
*/
function isPolicyCategoriesCollection(policyCategories: NonNullable<PolicyCategoriesLookup>): policyCategories is NonNullable<OnyxCollection<OnyxTypes.PolicyCategories>> {
return Object.keys(policyCategories).some((key) => key.startsWith(ONYXKEYS.COLLECTION.POLICY_CATEGORIES));
}

function getPolicyCategoriesForPolicyID(policyCategories: PolicyCategoriesLookup | undefined, policyID?: string): OnyxEntry<OnyxTypes.PolicyCategories> {
if (!policyCategories) {
return undefined;
}

const policyCategoriesKey = policyID ? `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}` : undefined;
if (policyCategoriesKey && Object.prototype.hasOwnProperty.call(policyCategories, policyCategoriesKey)) {
return (policyCategories as OnyxCollection<OnyxTypes.PolicyCategories>)?.[policyCategoriesKey];
if (!isPolicyCategoriesCollection(policyCategories)) {
return policyCategories;
}

const isPolicyCategoriesCollection = Object.keys(policyCategories).some((key) => key.startsWith(ONYXKEYS.COLLECTION.POLICY_CATEGORIES));
return isPolicyCategoriesCollection ? undefined : (policyCategories as OnyxEntry<OnyxTypes.PolicyCategories>);
const policyCategoriesKey = policyID ? `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}` : undefined;
return policyCategoriesKey ? policyCategories[policyCategoriesKey] : undefined;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/libs/TagsOptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function getTagVisibility({
shouldShowTags: boolean;
policy: Policy | undefined;
policyTags: OnyxEntry<PolicyTagLists>;
transaction: Transaction | undefined;
transaction: Pick<Transaction, 'tag'> | undefined;
}): TagVisibility[] {
const hasDependentTags = hasDependentTagsPolicyUtils(policy, policyTags);
const isMultilevelTags = isMultiLevelTagsPolicyUtils(policyTags);
Expand Down
10 changes: 5 additions & 5 deletions src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function isOdometerDistanceRequest(transaction: OnyxEntry<Transaction>): boolean
return transaction?.iouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE_ODOMETER;
}

function isScanRequest(transaction: OnyxEntry<Transaction>): boolean {
function isScanRequest(transaction: OnyxEntry<Pick<Transaction, 'iouRequestType'>>): boolean {
return transaction?.iouRequestType === CONST.IOU.REQUEST_TYPE.SCAN;
}

Expand Down Expand Up @@ -959,7 +959,7 @@ function getFormattedPostedDate(transaction: OnyxInputOrEntry<Transaction>, date
/**
* Return the currency field from the transaction, return the modifiedCurrency if present.
*/
function getCurrency(transaction: OnyxInputOrEntry<Transaction>): string {
function getCurrency(transaction: OnyxInputOrEntry<Pick<Transaction, 'modifiedCurrency' | 'currency'>>): string {
const currency = transaction?.modifiedCurrency ?? '';
if (currency) {
return currency;
Expand Down Expand Up @@ -1274,7 +1274,7 @@ function getExchangeRate(transaction: TransactionWithOptionalSearchFields, repor
* Return the tag from the transaction. When the tagIndex is passed, return the tag based on the index.
* This "tag" field has no "modified" complement.
*/
function getTag(transaction: OnyxInputOrEntry<Transaction>, tagIndex?: number): string {
function getTag(transaction: OnyxInputOrEntry<Pick<Transaction, 'tag'>>, tagIndex?: number): string {
if (tagIndex !== undefined) {
const tagsArray = getTagArrayFromName(transaction?.tag ?? '');
return tagsArray.at(tagIndex) ?? '';
Expand All @@ -1283,7 +1283,7 @@ function getTag(transaction: OnyxInputOrEntry<Transaction>, tagIndex?: number):
return transaction?.tag ?? '';
}

function getTagForDisplay(transaction: OnyxEntry<Transaction>, tagIndex?: number): string {
function getTagForDisplay(transaction: OnyxEntry<Pick<Transaction, 'tag'>>, tagIndex?: number): string {
return getCommaSeparatedTagNameWithSanitizedColons(getTag(transaction, tagIndex));
}

Expand All @@ -1310,7 +1310,7 @@ function isExpensifyCardTransaction(transaction: OnyxEntry<Transaction>): boolea
/**
* Determine whether a transaction is made with a centrally managed card (Expensify or Company Card).
*/
function isManagedCardTransaction(transaction: OnyxEntry<Transaction>): boolean {
function isManagedCardTransaction(transaction: OnyxEntry<Pick<Transaction, 'managedCard'>>): boolean {
return !!transaction?.managedCard;
}

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/Search/SearchUIUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5965,7 +5965,7 @@ describe('SearchUIUtils', () => {
CONST.SEARCH.SORT_ORDER.ASC,
undefined,
{policyCategories: policyCategoriesForSort},
) as TransactionListItemType[];
);
const descendingResult = SearchUIUtils.getSortedSections(
CONST.SEARCH.DATA_TYPES.EXPENSE,
'',
Expand All @@ -5976,10 +5976,10 @@ describe('SearchUIUtils', () => {
CONST.SEARCH.SORT_ORDER.DESC,
undefined,
{policyCategories: policyCategoriesForSort},
) as TransactionListItemType[];
);

expect(ascendingResult.map((transaction) => transaction.transactionID)).toEqual(['without-gl-code', 'gl-code-1010', 'gl-code-6100', 'gl-code-6200']);
expect(descendingResult.map((transaction) => transaction.transactionID)).toEqual(['gl-code-6200', 'gl-code-6100', 'gl-code-1010', 'without-gl-code']);
expect(ascendingResult.map((item) => ('transactionID' in item ? item.transactionID : undefined))).toEqual(['without-gl-code', 'gl-code-1010', 'gl-code-6100', 'gl-code-6200']);
expect(descendingResult.map((item) => ('transactionID' in item ? item.transactionID : undefined))).toEqual(['gl-code-6200', 'gl-code-6100', 'gl-code-1010', 'without-gl-code']);
});

it('should return getSortedReportData result when type is expense-report', () => {
Expand Down
Loading