From 769d6d4122f5ba2f0f7c6b7a511e2db4a094039a Mon Sep 17 00:00:00 2001 From: Yauheni Pasiukevich Date: Tue, 23 Jan 2024 16:52:36 +0100 Subject: [PATCH 1/9] [TS migration] Migrate 'Profile' page to TypeScript --- src/components/OfflineWithFeedback.tsx | 2 +- src/libs/Navigation/types.ts | 1 + src/libs/ReportUtils.ts | 2 +- src/pages/{ProfilePage.js => ProfilePage.tsx} | 197 ++++++++---------- 4 files changed, 90 insertions(+), 112 deletions(-) rename src/pages/{ProfilePage.js => ProfilePage.tsx} (62%) diff --git a/src/components/OfflineWithFeedback.tsx b/src/components/OfflineWithFeedback.tsx index 2c41864564a3..ba9ce9858d03 100644 --- a/src/components/OfflineWithFeedback.tsx +++ b/src/components/OfflineWithFeedback.tsx @@ -24,7 +24,7 @@ import MessagesRow from './MessagesRow'; type OfflineWithFeedbackProps = ChildrenProps & { /** The type of action that's pending */ - pendingAction?: OnyxCommon.PendingAction; + pendingAction?: OnyxCommon.PendingAction | null; /** Determine whether to hide the component's children if deletion is pending */ shouldHideOnDelete?: boolean; diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index d3df217c1342..7cad6d2bf558 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -158,6 +158,7 @@ type ProfileNavigatorParamList = { [SCREENS.PROFILE_ROOT]: { accountID: string; reportID: string; + backTo: Routes; }; }; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ba78d8a2cc38..3bf909bf14d5 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4646,7 +4646,7 @@ function shouldAutoFocusOnKeyPress(event: KeyboardEvent): boolean { /** * Navigates to the appropriate screen based on the presence of a private note for the current user. */ -function navigateToPrivateNotes(report: Report, session: Session) { +function navigateToPrivateNotes(report: OnyxEntry, session: OnyxEntry) { if (isEmpty(report) || isEmpty(session) || !session.accountID) { return; } diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.tsx similarity index 62% rename from src/pages/ProfilePage.js rename to src/pages/ProfilePage.tsx index c933e22dd8ea..6a157148c5ab 100755 --- a/src/pages/ProfilePage.js +++ b/src/pages/ProfilePage.tsx @@ -1,10 +1,9 @@ +import type {StackScreenProps} from '@react-navigation/stack'; import Str from 'expensify-common/lib/str'; -import lodashGet from 'lodash/get'; -import PropTypes from 'prop-types'; import React, {useEffect} from 'react'; import {ScrollView, View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; -import _ from 'underscore'; +import type {OnyxEntry} from 'react-native-onyx'; import AutoUpdateTime from '@components/AutoUpdateTime'; import Avatar from '@components/Avatar'; import BlockingView from '@components/BlockingViews/BlockingView'; @@ -20,132 +19,113 @@ import PressableWithoutFocus from '@components/Pressable/PressableWithoutFocus'; import ScreenWrapper from '@components/ScreenWrapper'; import Text from '@components/Text'; import UserDetailsTooltip from '@components/UserDetailsTooltip'; -import withLocalize, {withLocalizePropTypes} from '@components/withLocalize'; +import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import compose from '@libs/compose'; import Navigation from '@libs/Navigation/Navigation'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import {parsePhoneNumber} from '@libs/PhoneNumber'; import * as ReportUtils from '@libs/ReportUtils'; import * as UserUtils from '@libs/UserUtils'; import * as ValidationUtils from '@libs/ValidationUtils'; +import type {ProfileNavigatorParamList} from '@navigation/types'; import variables from '@styles/variables'; -import * as PersonalDetails from '@userActions/PersonalDetails'; -import * as Report from '@userActions/Report'; -import * as Session from '@userActions/Session'; +import * as PersonalDetailsActions from '@userActions/PersonalDetails'; +import * as ReportActions from '@userActions/Report'; +import * as SessionActions from '@userActions/Session'; import CONST from '@src/CONST'; +import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import personalDetailsPropType from './personalDetailsPropType'; +import type SCREENS from '@src/SCREENS'; +import type {PersonalDetails, PersonalDetailsList, Report, Session} from '@src/types/onyx'; +import {isEmptyObject} from '@src/types/utils/EmptyObject'; +import type {EmptyObject} from '@src/types/utils/EmptyObject'; -const matchType = PropTypes.shape({ - params: PropTypes.shape({ - /** accountID passed via route /a/:accountID */ - accountID: PropTypes.string, +type ProfilePageOnyxProps = { + /** The personal details of the person who is logged in */ + personalDetails: OnyxEntry; - /** report ID passed */ - reportID: PropTypes.string, - }), -}); - -const propTypes = { - /* Onyx Props */ - - /** The personal details of all users */ - personalDetails: PropTypes.objectOf(personalDetailsPropType), - - /** Route params */ - route: matchType.isRequired, + /** The report currently being looked at */ + report: OnyxEntry; /** Session info for the currently logged in user. */ - session: PropTypes.shape({ - /** Currently logged in user accountID */ - accountID: PropTypes.number, - }), - - ...withLocalizePropTypes, + session: OnyxEntry; }; -const defaultProps = { - // When opening someone else's profile (via deep link) before login, this is empty - personalDetails: {}, - session: { - accountID: 0, - }, -}; +type ProfilePageProps = ProfilePageOnyxProps & StackScreenProps; /** * Gets the phone number to display for SMS logins - * - * @param {Object} details - * @param {String} details.login - * @param {String} details.displayName - * @returns {String} */ -const getPhoneNumber = (details) => { - // If the user hasn't set a displayName, it is set to their phone number, so use that - const displayName = lodashGet(details, 'displayName', ''); +const getPhoneNumber = ({login = '', displayName = ''}: PersonalDetails | EmptyObject): string | undefined => { + // If the user hasn't set a displayName, it is set to their phone number const parsedPhoneNumber = parsePhoneNumber(displayName); + if (parsedPhoneNumber.possible) { - return parsedPhoneNumber.number.e164; + return parsedPhoneNumber?.number?.e164; } // If the user has set a displayName, get the phone number from the SMS login - return details.login ? Str.removeSMSDomain(details.login) : ''; + return login ? Str.removeSMSDomain(login) : ''; }; -function ProfilePage(props) { +function ProfilePage({personalDetails = {}, route, session, report}: ProfilePageProps) { const styles = useThemeStyles(); - const accountID = Number(lodashGet(props.route.params, 'accountID', 0)); - const details = lodashGet(props.personalDetails, accountID, ValidationUtils.isValidAccountRoute(accountID) ? {} : {isloading: false}); + const {translate, formatPhoneNumber} = useLocalize(); + const accountID = Number(route.params?.accountID ?? 0); + const details: PersonalDetails | EmptyObject = personalDetails?.[accountID] ?? (ValidationUtils.isValidAccountRoute(accountID) ? {} : {isLoading: false, accountID: 0, avatar: ''}); const displayName = PersonalDetailsUtils.getDisplayNameOrDefault(details); - const avatar = lodashGet(details, 'avatar', UserUtils.getDefaultAvatar()); - const fallbackIcon = lodashGet(details, 'fallbackIcon', ''); - const login = lodashGet(details, 'login', ''); - const timezone = lodashGet(details, 'timezone', {}); + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + const avatar = details?.avatar || UserUtils.getDefaultAvatar(); + const fallbackIcon = details?.fallbackIcon ?? ''; + const login = details?.login ?? ''; + const timezone = details?.timezone; // If we have a reportID param this means that we // arrived here via the ParticipantsPage and should be allowed to navigate back to it - const shouldShowLocalTime = !ReportUtils.hasAutomatedExpensifyAccountIDs([accountID]) && !_.isEmpty(timezone); - let pronouns = lodashGet(details, 'pronouns', ''); - if (pronouns && pronouns.startsWith(CONST.PRONOUNS.PREFIX)) { + const shouldShowLocalTime = !ReportUtils.hasAutomatedExpensifyAccountIDs([accountID]) && !isEmptyObject(timezone); + let pronouns = details?.pronouns ?? ''; + if (pronouns?.startsWith(CONST.PRONOUNS.PREFIX)) { const localeKey = pronouns.replace(CONST.PRONOUNS.PREFIX, ''); - pronouns = props.translate(`pronouns.${localeKey}`); + pronouns = translate(`pronouns.${localeKey}` as TranslationPaths); } const isSMSLogin = Str.isSMSLogin(login); const phoneNumber = getPhoneNumber(details); const phoneOrEmail = isSMSLogin ? getPhoneNumber(details) : login; - const isCurrentUser = props.session.accountID === accountID; - const hasMinimumDetails = !_.isEmpty(details.avatar); - const isLoading = lodashGet(details, 'isLoading', false) || _.isEmpty(details); + const isCurrentUser = session?.accountID === accountID; + const hasMinimumDetails = !isEmptyObject(details.avatar); + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + const isLoading = details?.isLoading || false || isEmptyObject(details); // If the API returns an error for some reason there won't be any details and isLoading will get set to false, so we want to show a blocking screen const shouldShowBlockingView = !hasMinimumDetails && !isLoading; - const statusEmojiCode = lodashGet(details, 'status.emojiCode', ''); - const statusText = lodashGet(details, 'status.text', ''); + const statusEmojiCode = details?.status?.emojiCode ?? ''; + const statusText = details?.status?.text ?? ''; const hasStatus = !!statusEmojiCode; const statusContent = `${statusEmojiCode} ${statusText}`; - const navigateBackTo = lodashGet(props.route, 'params.backTo'); + const navigateBackTo = route?.params?.backTo; - const shouldShowNotificationPreference = !_.isEmpty(props.report) && props.report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; - const notificationPreference = shouldShowNotificationPreference ? props.translate(`notificationPreferencesPage.notificationPreferences.${props.report.notificationPreference}`) : ''; + const shouldShowNotificationPreference = !isEmptyObject(report) && report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; + const notificationPreference = shouldShowNotificationPreference + ? translate(`notificationPreferencesPage.notificationPreferences.${report.notificationPreference}` as TranslationPaths) + : ''; // eslint-disable-next-line rulesdir/prefer-early-return useEffect(() => { if (ValidationUtils.isValidAccountRoute(accountID) && !hasMinimumDetails) { - PersonalDetails.openPublicProfilePage(accountID); + PersonalDetailsActions.openPublicProfilePage(accountID); } }, [accountID, hasMinimumDetails]); return ( Navigation.goBack(navigateBackTo)} /> @@ -155,10 +135,10 @@ function ProfilePage(props) { Navigation.navigate(ROUTES.PROFILE_AVATAR.getRoute(String(accountID)))} - accessibilityLabel={props.translate('common.profile')} + accessibilityLabel={translate('common.profile')} accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON} > - + - {props.translate('statusPage.status')} + {translate('statusPage.status')} {statusContent} @@ -194,11 +174,11 @@ function ProfilePage(props) { style={[styles.textLabelSupporting, styles.mb1]} numberOfLines={1} > - {props.translate(isSMSLogin ? 'common.phoneNumber' : 'common.email')} + {translate(isSMSLogin ? 'common.phoneNumber' : 'common.email')} - + - {isSMSLogin ? props.formatPhoneNumber(phoneNumber) : login} + {isSMSLogin ? formatPhoneNumber(phoneNumber ?? '') : login} @@ -209,7 +189,7 @@ function ProfilePage(props) { style={[styles.textLabelSupporting, styles.mb1]} numberOfLines={1} > - {props.translate('profilePage.preferredPronouns')} + {translate('profilePage.preferredPronouns')} {pronouns} @@ -220,30 +200,30 @@ function ProfilePage(props) { Navigation.navigate(ROUTES.REPORT_SETTINGS_NOTIFICATION_PREFERENCES.getRoute(props.report.reportID))} + description={translate('notificationPreferencesPage.label')} + onPress={() => Navigation.navigate(ROUTES.REPORT_SETTINGS_NOTIFICATION_PREFERENCES.getRoute(report.reportID))} wrapperStyle={[styles.mtn6, styles.mb5]} /> )} - {!isCurrentUser && !Session.isAnonymousUser() && ( + {!isCurrentUser && !SessionActions.isAnonymousUser() && ( Report.navigateToAndOpenReportWithAccountIDs([accountID])} + onPress={() => ReportActions.navigateToAndOpenReportWithAccountIDs([accountID])} wrapperStyle={styles.breakAll} shouldShowRightIcon /> )} - {!_.isEmpty(props.report) && ( + {!isEmptyObject(report) && ( ReportUtils.navigateToPrivateNotes(props.report, props.session)} + onPress={() => ReportUtils.navigateToPrivateNotes(report, session)} wrapperStyle={styles.breakAll} shouldShowRightIcon - brickRoadIndicator={Report.hasErrorInPrivateNotes(props.report) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''} + brickRoadIndicator={ReportActions.hasErrorInPrivateNotes(report) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} /> )} @@ -254,9 +234,8 @@ function ProfilePage(props) { icon={Illustrations.ToddBehindCloud} iconWidth={variables.modalTopIconWidth} iconHeight={variables.modalTopIconHeight} - title={props.translate('notFound.notHere')} + title={translate('notFound.notHere')} shouldShowLink - link={props.translate('notFound.goBackHome')} /> )} @@ -264,28 +243,26 @@ function ProfilePage(props) { ); } -ProfilePage.propTypes = propTypes; -ProfilePage.defaultProps = defaultProps; ProfilePage.displayName = 'ProfilePage'; -export default compose( - withLocalize, - withOnyx({ - personalDetails: { - key: ONYXKEYS.PERSONAL_DETAILS_LIST, - }, - session: { - key: ONYXKEYS.SESSION, - }, - report: { - key: ({route, session}) => { - const accountID = Number(lodashGet(route.params, 'accountID', 0)); - const reportID = lodashGet(ReportUtils.getChatByParticipants([accountID]), 'reportID', ''); - if ((session && Number(session.accountID) === accountID) || Session.isAnonymousUser() || !reportID) { - return null; - } - return `${ONYXKEYS.COLLECTION.REPORT}${reportID}`; - }, +export default withOnyx({ + personalDetails: { + key: ONYXKEYS.PERSONAL_DETAILS_LIST, + }, + session: { + key: ONYXKEYS.SESSION, + }, + report: { + key: ({route, session}) => { + const accountID = Number(route.params?.accountID ?? 0); + const reportID = ReportUtils.getChatByParticipants([accountID])?.reportID ?? ''; + + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + if ((session && Number(session.accountID) === accountID) || SessionActions.isAnonymousUser() || !reportID) { + return `${ONYXKEYS.COLLECTION.REPORT}0`; + } + + return `${ONYXKEYS.COLLECTION.REPORT}${reportID}`; }, - }), -)(ProfilePage); + }, +})(ProfilePage); From bca8c01c4154c7eb98f2ee654753a30e9ac95deb Mon Sep 17 00:00:00 2001 From: Yauheni Pasiukevich Date: Wed, 14 Feb 2024 15:58:01 +0100 Subject: [PATCH 2/9] fix comments --- src/pages/ProfilePage.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pages/ProfilePage.tsx b/src/pages/ProfilePage.tsx index 6a157148c5ab..d7925cdc3607 100755 --- a/src/pages/ProfilePage.tsx +++ b/src/pages/ProfilePage.tsx @@ -69,7 +69,7 @@ const getPhoneNumber = ({login = '', displayName = ''}: PersonalDetails | EmptyO return login ? Str.removeSMSDomain(login) : ''; }; -function ProfilePage({personalDetails = {}, route, session, report}: ProfilePageProps) { +function ProfilePage({personalDetails, route, session, report}: ProfilePageProps) { const styles = useThemeStyles(); const {translate, formatPhoneNumber} = useLocalize(); const accountID = Number(route.params?.accountID ?? 0); @@ -97,8 +97,7 @@ function ProfilePage({personalDetails = {}, route, session, report}: ProfilePage const isCurrentUser = session?.accountID === accountID; const hasMinimumDetails = !isEmptyObject(details.avatar); - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const isLoading = details?.isLoading || false || isEmptyObject(details); + const isLoading = Boolean(details?.isLoading) || false || isEmptyObject(details); // If the API returns an error for some reason there won't be any details and isLoading will get set to false, so we want to show a blocking screen const shouldShowBlockingView = !hasMinimumDetails && !isLoading; @@ -257,8 +256,7 @@ export default withOnyx({ const accountID = Number(route.params?.accountID ?? 0); const reportID = ReportUtils.getChatByParticipants([accountID])?.reportID ?? ''; - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if ((session && Number(session.accountID) === accountID) || SessionActions.isAnonymousUser() || !reportID) { + if ((Boolean(session) && Number(session?.accountID) === accountID) || SessionActions.isAnonymousUser() || !reportID) { return `${ONYXKEYS.COLLECTION.REPORT}0`; } From f7109449c76c43cf6a76cc7bacb48cd08e979a56 Mon Sep 17 00:00:00 2001 From: Yauheni Pasiukevich Date: Wed, 21 Feb 2024 16:20:50 +0100 Subject: [PATCH 3/9] remove redundant condition --- src/pages/ProfilePage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ProfilePage.tsx b/src/pages/ProfilePage.tsx index 4748418d22f4..7971220f5b02 100755 --- a/src/pages/ProfilePage.tsx +++ b/src/pages/ProfilePage.tsx @@ -98,7 +98,7 @@ function ProfilePage({personalDetails, route, session, report}: ProfilePageProps const isCurrentUser = session?.accountID === accountID; const hasMinimumDetails = !isEmptyObject(details.avatar); - const isLoading = Boolean(details?.isLoading) || false || isEmptyObject(details); + const isLoading = Boolean(details?.isLoading) || isEmptyObject(details); // If the API returns an error for some reason there won't be any details and isLoading will get set to false, so we want to show a blocking screen const shouldShowBlockingView = !hasMinimumDetails && !isLoading; From 27480fe58fc863175852ea697ef9058eabee4dfe Mon Sep 17 00:00:00 2001 From: Yauheni Pasiukevich Date: Tue, 27 Feb 2024 13:32:27 +0100 Subject: [PATCH 4/9] add comment --- src/pages/ProfilePage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ProfilePage.tsx b/src/pages/ProfilePage.tsx index 7971220f5b02..da87edb7b5a0 100755 --- a/src/pages/ProfilePage.tsx +++ b/src/pages/ProfilePage.tsx @@ -78,7 +78,7 @@ function ProfilePage({personalDetails, route, session, report}: ProfilePageProps const displayName = PersonalDetailsUtils.getDisplayNameOrDefault(details); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const avatar = details?.avatar || UserUtils.getDefaultAvatar(); + const avatar = details?.avatar || UserUtils.getDefaultAvatar(); // we can have an empty string and in this case, we need to show the default avatar const fallbackIcon = details?.fallbackIcon ?? ''; const login = details?.login ?? ''; const timezone = details?.timezone; From 3173fa068ec945108dcec92d645315452e2f1df8 Mon Sep 17 00:00:00 2001 From: Yauheni Pasiukevich Date: Tue, 27 Feb 2024 13:41:43 +0100 Subject: [PATCH 5/9] fix type --- src/pages/ProfilePage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ProfilePage.tsx b/src/pages/ProfilePage.tsx index da87edb7b5a0..67afe1a277d9 100755 --- a/src/pages/ProfilePage.tsx +++ b/src/pages/ProfilePage.tsx @@ -179,7 +179,7 @@ function ProfilePage({personalDetails, route, session, report}: ProfilePageProps - {isSMSLogin ? formatPhoneNumber(phoneNumber) : login} + {isSMSLogin ? formatPhoneNumber(phoneNumber ?? '') : login} From d0d42d56033fad5a71ed520096301912305ef477 Mon Sep 17 00:00:00 2001 From: Yauheni Pasiukevich Date: Mon, 4 Mar 2024 14:25:33 +0100 Subject: [PATCH 6/9] revert eslint disable for logical OR --- src/pages/ProfilePage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/ProfilePage.tsx b/src/pages/ProfilePage.tsx index ceec3acc3c3b..e1b3d9edfbef 100755 --- a/src/pages/ProfilePage.tsx +++ b/src/pages/ProfilePage.tsx @@ -78,6 +78,7 @@ function ProfilePage({personalDetails, route, session, report, reports}: Profile const details: PersonalDetails | EmptyObject = personalDetails?.[accountID] ?? (ValidationUtils.isValidAccountRoute(accountID) ? {} : {isLoading: false, accountID: 0, avatar: ''}); const displayName = PersonalDetailsUtils.getDisplayNameOrDefault(details, undefined, undefined, isCurrentUser); + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const avatar = details?.avatar || UserUtils.getDefaultAvatar(); // we can have an empty string and in this case, we need to show the default avatar const fallbackIcon = details?.fallbackIcon ?? ''; const login = details?.login ?? ''; From b7f8dae35670df967313b0e06ec14edf065edad8 Mon Sep 17 00:00:00 2001 From: Yauheni Pasiukevich Date: Wed, 6 Mar 2024 11:11:44 +0100 Subject: [PATCH 7/9] update selector with not null type --- src/pages/ProfilePage.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pages/ProfilePage.tsx b/src/pages/ProfilePage.tsx index 4f05291cf505..3c94bfde657e 100755 --- a/src/pages/ProfilePage.tsx +++ b/src/pages/ProfilePage.tsx @@ -46,7 +46,10 @@ type ProfilePageOnyxProps = { /** The report currently being looked at */ report: OnyxEntry; - /** The list of all reports */ + /** The list of all reports + * ONYXKEYS.COLLECTION.REPORT is needed for report key function + */ + // eslint-disable-next-line react/no-unused-prop-types reports: OnyxCollection; /** Session info for the currently logged in user. */ @@ -70,7 +73,7 @@ const getPhoneNumber = ({login = '', displayName = ''}: PersonalDetails | EmptyO return login ? Str.removeSMSDomain(login) : ''; }; -function ProfilePage({personalDetails, route, session, report, reports}: ProfilePageProps) { +function ProfilePage({personalDetails, route, session, report}: ProfilePageProps) { const styles = useThemeStyles(); const {translate, formatPhoneNumber} = useLocalize(); const accountID = Number(route.params?.accountID ?? 0); @@ -242,8 +245,8 @@ ProfilePage.displayName = 'ProfilePage'; * This function narrow down the data from Onyx to just the properties that we want to trigger a re-render of the component. This helps minimize re-rendering * and makes the entire component more performant because it's not re-rendering when a bunch of properties change which aren't ever used in the UI. */ -const chatReportSelector = (report: OnyxEntry): OnyxEntry => - report && { +const chatReportSelector = (report: OnyxEntry): Report => + (report && { reportID: report.reportID, participantAccountIDs: report.participantAccountIDs, parentReportID: report.parentReportID, @@ -251,7 +254,7 @@ const chatReportSelector = (report: OnyxEntry): OnyxEntry => type: report.type, chatType: report.chatType, isPolicyExpenseChat: report.isPolicyExpenseChat, - }; + }) as Report; export default withOnyx({ reports: { From 23a576a2a55424e4f00981865382a3c2a86f3ef0 Mon Sep 17 00:00:00 2001 From: Yauheni Pasiukevich Date: Wed, 6 Mar 2024 11:55:49 +0100 Subject: [PATCH 8/9] fix prettier --- src/pages/ProfilePage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/ProfilePage.tsx b/src/pages/ProfilePage.tsx index 3c94bfde657e..3c6d082595cf 100755 --- a/src/pages/ProfilePage.tsx +++ b/src/pages/ProfilePage.tsx @@ -46,9 +46,9 @@ type ProfilePageOnyxProps = { /** The report currently being looked at */ report: OnyxEntry; - /** The list of all reports + /** The list of all reports * ONYXKEYS.COLLECTION.REPORT is needed for report key function - */ + */ // eslint-disable-next-line react/no-unused-prop-types reports: OnyxCollection; From 8749ad1984e8b3b9519eab927a54ab52eb94976c Mon Sep 17 00:00:00 2001 From: Yauheni Pasiukevich Date: Thu, 7 Mar 2024 14:39:12 +0100 Subject: [PATCH 9/9] remove empty line --- src/pages/ProfilePage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/ProfilePage.tsx b/src/pages/ProfilePage.tsx index 3c6d082595cf..486bf53b6a28 100755 --- a/src/pages/ProfilePage.tsx +++ b/src/pages/ProfilePage.tsx @@ -275,7 +275,6 @@ export default withOnyx({ if ((Boolean(session) && Number(session?.accountID) === accountID) || SessionActions.isAnonymousUser() || !reportID) { return `${ONYXKEYS.COLLECTION.REPORT}0`; } - return `${ONYXKEYS.COLLECTION.REPORT}${reportID}`; }, },