Repository navigation
Removed useOptionsList from IOURequestEditReportCommon.tsx #82506
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,8 @@ | ||
| import React, {useCallback, useMemo, useState} from 'react'; | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
| import ConfirmModal from '@components/ConfirmModal'; | ||
| // eslint-disable-next-line no-restricted-imports | ||
| import * as Expensicons from '@components/Icon/Expensicons'; | ||
| import MenuItem from '@components/MenuItem'; | ||
| import {useOptionsList} from '@components/OptionListContextProvider'; | ||
| import {usePersonalDetails} from '@components/OnyxListItemProvider'; | ||
| import SelectionList from '@components/SelectionList'; | ||
| import InviteMemberListItem from '@components/SelectionList/ListItem/InviteMemberListItem'; | ||
| import type {ListItem} from '@components/SelectionList/types'; | ||
|
|
@@ -19,7 +17,7 @@ import usePolicyForMovingExpenses from '@hooks/usePolicyForMovingExpenses'; | |
| import useReportTransactions from '@hooks/useReportTransactions'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import {isPolicyAdmin} from '@libs/PolicyUtils'; | ||
| import {canAddTransaction, getPolicyName, getReportName, isIOUReport, isOpenReport, isReportOwner, sortOutstandingReportsBySelected} from '@libs/ReportUtils'; | ||
| import {canAddTransaction, getIconsForExpenseReport, isIOUReport, isOpenReport, isReportOwner, sortOutstandingReportsBySelected} from '@libs/ReportUtils'; | ||
| import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils'; | ||
| import {isPerDiemRequest as isPerDiemRequestUtil} from '@libs/TransactionUtils'; | ||
| import CONST from '@src/CONST'; | ||
|
|
@@ -66,9 +64,9 @@ function IOURequestEditReportCommon({ | |
| createReport, | ||
| isPerDiemRequest, | ||
| }: Props) { | ||
| const icons = useMemoizedLazyExpensifyIcons(['Document']); | ||
| const icons = useMemoizedLazyExpensifyIcons(['Close', 'Document']); | ||
| const {translate, localeCompare} = useLocalize(); | ||
| const {options} = useOptionsList(); | ||
| const personalDetails = usePersonalDetails(); | ||
| const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true}); | ||
| const [allTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {canBeMissing: true}); | ||
| const currentUserPersonalDetails = useCurrentUserPersonalDetails(); | ||
|
|
@@ -139,22 +137,20 @@ function IOURequestEditReportCommon({ | |
| return isReportPolicyAdmin || isReportManager; | ||
| }) | ||
| .map((report) => { | ||
| const matchingOption = options.reports.find((option) => option.reportID === report.reportID); | ||
| const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`]; | ||
| return { | ||
| ...(matchingOption ?? report), | ||
| // We are shallow copying properties from matchingOption, so if it has a brickRoadIndicator, it will display RBR. | ||
| // We set it to null here to prevent showing RBR for reports https://github.com/Expensify/App/issues/65960. | ||
| brickRoadIndicator: null, | ||
| alternateText: getPolicyName({report}) ?? matchingOption?.alternateText, | ||
| // eslint-disable-next-line @typescript-eslint/no-deprecated | ||
| text: getReportName(report), | ||
| alternateText: policy?.name, | ||
| text: report.reportName, | ||
| value: report.reportID, | ||
| keyForList: report.reportID, | ||
| isSelected: report.reportID === selectedReportID, | ||
| policyID: matchingOption?.policyID ?? report.policyID, | ||
| policyID: report.policyID, | ||
| reportID: report.reportID, | ||
| icons: getIconsForExpenseReport(report, personalDetails, policy), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did we miss:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hoangzinh, are you seeing any difference in the list from staging? If yes, lemme know; otherwise, these fields are fine.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let me test it again
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't find any regression. Let's keep current attributes mapping.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not very clear on this change either, I feel like it might bring some regressions but let's see |
||
| }; | ||
| }); | ||
| }, [debouncedSearchValue, outstandingReports, selectedReportID, options.reports, localeCompare, allPolicies, currentUserPersonalDetails.accountID]); | ||
| }, [debouncedSearchValue, outstandingReports, selectedReportID, personalDetails, localeCompare, allPolicies, currentUserPersonalDetails.accountID]); | ||
|
|
||
| const navigateBack = () => { | ||
| Navigation.goBack(backTo); | ||
|
|
@@ -301,7 +297,7 @@ function IOURequestEditReportCommon({ | |
| onPress={removeFromReport} | ||
| title={translate('iou.removeFromReport')} | ||
| description={translate('iou.moveToPersonalSpace')} | ||
| icon={Expensicons.Close} | ||
| icon={icons.Close} | ||
| /> | ||
| )} | ||
| {createReportOption} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,11 +67,6 @@ describe('ReportUtils', () => { | |
| expect(ReportUtils.getIconsForPolicyExpenseChat).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('does not export getIconsForExpenseReport', () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't object to exporting this function for use elsewhere. However, should we investigate why the author doesn't want to export it? |
||
| // @ts-expect-error the test is asserting that it's undefined, so the TS error is normal | ||
| expect(ReportUtils.getIconsForExpenseReport).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('does not export getIconsForInvoiceReport', () => { | ||
| // @ts-expect-error the test is asserting that it's undefined, so the TS error is normal | ||
| expect(ReportUtils.getIconsForInvoiceReport).toBeUndefined(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.