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 'OptionsListUtils.js' lib to TypeScript #32470

Merged
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
1c2690a
ref: move OptionsListUtils to TS
kubabutkiewicz Oct 2, 2023
71c71bb
Merge branch 'main' into ts-migration/OptionsListUtils-lib
kubabutkiewicz Oct 2, 2023
d67f9f7
fix: removed loadshGet usage
kubabutkiewicz Oct 2, 2023
8f8f2c0
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Dec 4, 2023
ff9ef80
fix: types
kubabutkiewicz Dec 5, 2023
3afff90
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Dec 5, 2023
1cc23ca
fix: types
kubabutkiewicz Dec 5, 2023
4bd6c2e
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Dec 5, 2023
59e5bf5
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Dec 6, 2023
b255727
fix: types
kubabutkiewicz Dec 7, 2023
8c315e8
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Dec 7, 2023
905b5e3
fix: types
kubabutkiewicz Dec 7, 2023
5e92f73
fix: tests
kubabutkiewicz Dec 8, 2023
b0c7f4c
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Dec 8, 2023
feadbf2
fix: tests
kubabutkiewicz Dec 8, 2023
dae570c
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Dec 11, 2023
60a94cc
fix: added return type
kubabutkiewicz Dec 11, 2023
f919766
fix: adressing comments
kubabutkiewicz Dec 12, 2023
f6e8063
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Dec 12, 2023
f34bc7a
fix: added native implementations of lodash methods and add tests for…
kubabutkiewicz Dec 13, 2023
6d4fbad
fix: types issues
kubabutkiewicz Dec 13, 2023
da5b440
fix: resolve comments
kubabutkiewicz Dec 13, 2023
92e46e6
fix: created lodash set eqiuvalent
kubabutkiewicz Dec 13, 2023
40df8fd
fix: types error
kubabutkiewicz Dec 13, 2023
f1e7619
fix: lint errors
kubabutkiewicz Dec 13, 2023
46aa206
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Dec 14, 2023
f16c0d5
fix: adress comments
kubabutkiewicz Dec 15, 2023
27fcd37
fix: typecheck
kubabutkiewicz Dec 15, 2023
414a3a4
fix: removed unnecessary null
kubabutkiewicz Dec 15, 2023
7d41e87
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Dec 18, 2023
ab76604
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Dec 19, 2023
ffb65dc
fix: adress comments
kubabutkiewicz Dec 19, 2023
8154e3b
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Dec 21, 2023
b676aa9
fix: address comments
kubabutkiewicz Dec 21, 2023
583221b
Fix import and type issues in AvatarWithDisplayName and SidebarUtils
kubabutkiewicz Dec 21, 2023
ec874bb
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 2, 2024
db02416
fix: resolve comment
kubabutkiewicz Jan 2, 2024
d517e02
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 3, 2024
13f058e
fix: tests and typecheck
kubabutkiewicz Jan 3, 2024
260cf9c
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 4, 2024
2478377
fix: types for taxes feature
kubabutkiewicz Jan 4, 2024
b09535d
fix: resolve comments
kubabutkiewicz Jan 4, 2024
efed80c
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 8, 2024
29d4061
fix: resolve comments
kubabutkiewicz Jan 8, 2024
52278e7
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 10, 2024
9b58aaa
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 15, 2024
d1b7d94
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 15, 2024
49c5c6b
fix: types
kubabutkiewicz Jan 15, 2024
d29588e
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 16, 2024
a44e5ac
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 17, 2024
a9c696c
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 18, 2024
82d1ed8
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 22, 2024
72235f7
fix: typecheck
kubabutkiewicz Jan 22, 2024
62b4524
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 23, 2024
75287d8
fix: use || instead of ??
kubabutkiewicz Jan 23, 2024
3848994
fix: bug that text was not displayed for room member invite , resolve…
kubabutkiewicz Jan 23, 2024
7e759d4
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 25, 2024
500833d
fix: typecheck
kubabutkiewicz Jan 25, 2024
691fef8
fix: typecheck
kubabutkiewicz Jan 25, 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
5 changes: 2 additions & 3 deletions src/components/AnonymousReportFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from 'react';
import {Text, View} from 'react-native';
import {OnyxCollection} from 'react-native-onyx';
import {OnyxEntry} from 'react-native-onyx/lib/types';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as Session from '@userActions/Session';
import {PersonalDetails, Report} from '@src/types/onyx';
import {PersonalDetailsList, Report} from '@src/types/onyx';
import AvatarWithDisplayName from './AvatarWithDisplayName';
import Button from './Button';
import ExpensifyWordmark from './ExpensifyWordmark';
Expand All @@ -18,7 +17,7 @@ type AnonymousReportFooterProps = {
isSmallSizeLayout?: boolean;

/** Personal details of all the users */
personalDetails: OnyxCollection<PersonalDetails>;
personalDetails: OnyxEntry<PersonalDetailsList>;
};

function AnonymousReportFooter({isSmallSizeLayout = false, personalDetails, report}: AnonymousReportFooterProps) {
Expand Down
8 changes: 4 additions & 4 deletions src/components/AvatarWithDisplayName.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useCallback, useEffect, useRef} from 'react';
import {View} from 'react-native';
import {OnyxCollection, OnyxEntry, withOnyx} from 'react-native-onyx';
import {OnyxEntry, withOnyx} from 'react-native-onyx';
import {ValueOf} from 'type-fest';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
Expand All @@ -11,7 +11,7 @@ import * as ReportUtils from '@libs/ReportUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import {PersonalDetails, Policy, Report, ReportActions} from '@src/types/onyx';
import {PersonalDetails, PersonalDetailsList, Policy, Report, ReportActions} from '@src/types/onyx';
import DisplayNames from './DisplayNames';
import MultipleAvatars from './MultipleAvatars';
import ParentNavigationSubtitle from './ParentNavigationSubtitle';
Expand All @@ -35,7 +35,7 @@ type AvatarWithDisplayNameProps = AvatarWithDisplayNamePropsWithOnyx & {
size?: ValueOf<typeof CONST.AVATAR_SIZE>;

/** Personal details of all the users */
personalDetails: OnyxCollection<PersonalDetails>;
personalDetails: OnyxEntry<PersonalDetailsList>;

/** Whether if it's an unauthenticated user */
isAnonymous?: boolean;
Expand All @@ -62,7 +62,7 @@ function AvatarWithDisplayName({
const isMoneyRequestOrReport = ReportUtils.isMoneyRequestReport(report) || ReportUtils.isMoneyRequest(report);
const icons = ReportUtils.getIcons(report, personalDetails, null, '', -1, policy);
const ownerPersonalDetails = OptionsListUtils.getPersonalDetailsForAccountIDs(report?.ownerAccountID ? [report.ownerAccountID] : [], personalDetails);
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(Object.values(ownerPersonalDetails), false);
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(Object.values(ownerPersonalDetails) as PersonalDetails[], false);
const shouldShowSubscriptAvatar = ReportUtils.shouldReportShowSubscript(report);
const isExpenseRequest = ReportUtils.isExpenseRequest(report);
const avatarBorderColor = isAnonymous ? theme.highlightBG : theme.componentBG;
Expand Down
3 changes: 2 additions & 1 deletion src/components/OptionRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ function OptionRow({
shouldHaveOptionSeparator && styles.borderTop,
!onSelectRow && !isOptionDisabled ? styles.cursorDefault : null,
]}
accessibilityLabel={option.text}
accessible
kubabutkiewicz marked this conversation as resolved.
Show resolved Hide resolved
accessibilityLabel={option.text ?? ''}
role={CONST.ROLE.BUTTON}
hoverDimmingValue={1}
hoverStyle={!optionIsFocused ? hoverStyle ?? styles.sidebarLinkHover : undefined}
Expand Down
6 changes: 1 addition & 5 deletions src/components/ReportWelcomeText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP
const isDefault = !(isChatRoom || isPolicyExpenseChat);
const participantAccountIDs = report?.participantAccountIDs ?? [];
const isMultipleParticipant = participantAccountIDs.length > 1;
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(
// @ts-expect-error TODO: Remove this once OptionsListUtils (https://github.com/Expensify/App/issues/24921) is migrated to TypeScript.
OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails),
isMultipleParticipant,
);
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails), isMultipleParticipant);
const isUserPolicyAdmin = PolicyUtils.isPolicyAdmin(policy);
const roomWelcomeMessage = ReportUtils.getRoomWelcomeMessage(report, isUserPolicyAdmin);
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, policy, participantAccountIDs);
Expand Down
1 change: 0 additions & 1 deletion src/libs/GroupChatUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ function getGroupChatName(report: Report): string | undefined {
const participants = report.participantAccountIDs ?? [];
const isMultipleParticipantReport = participants.length > 1;
const participantPersonalDetails = OptionsListUtils.getPersonalDetailsForAccountIDs(participants, allPersonalDetails ?? {});
// @ts-expect-error Error will gone when OptionsListUtils will be migrated to Typescript
kubabutkiewicz marked this conversation as resolved.
Show resolved Hide resolved
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(participantPersonalDetails, isMultipleParticipantReport);
return ReportUtils.getDisplayNamesStringFromTooltips(displayNamesWithTooltips);
}
Expand Down
10 changes: 5 additions & 5 deletions src/libs/ModifiedExpenseMessage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {format} from 'date-fns';
import Onyx from 'react-native-onyx';
import Onyx, {OnyxEntry} from 'react-native-onyx';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import {PolicyTags, ReportAction} from '@src/types/onyx';
Expand Down Expand Up @@ -93,12 +93,12 @@ function getForDistanceRequest(newDistance: string, oldDistance: string, newAmou
* ModifiedExpense::getNewDotComment in Web-Expensify should match this.
* If we change this function be sure to update the backend as well.
*/
function getForReportAction(reportAction: ReportAction): string {
if (reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE) {
function getForReportAction(reportAction: OnyxEntry<ReportAction>): string {
if (reportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE) {
return '';
}
const reportActionOriginalMessage = reportAction.originalMessage as ExpenseOriginalMessage | undefined;
const policyID = ReportUtils.getReportPolicyID(reportAction.reportID) ?? '';
const reportActionOriginalMessage = reportAction?.originalMessage as ExpenseOriginalMessage | undefined;
const policyID = ReportUtils.getReportPolicyID(reportAction?.reportID) ?? '';
const policyTags = allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`] ?? {};
const policyTagListName = PolicyUtils.getTagListName(policyTags) || Localize.translateLocal('common.tag');

Expand Down
Loading
Loading