Skip to content

Commit fc24c21

Browse files
AndrewGableOSBotify
authored andcommitted
Merge pull request #60319 from Expensify/revert-60034-fix/59984-unavalaible-workspace
Revert "Enhance Search and Report Components with Policy Integration" (cherry picked from commit e10a748) (CP triggered by roryabraham)
1 parent 2143e70 commit fc24c21

5 files changed

Lines changed: 7 additions & 41 deletions

File tree

src/components/Search/SearchList.tsx

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import React, {forwardRef, useCallback, useEffect, useImperativeHandle, useRef,
33
import type {ForwardedRef} from 'react';
44
import {View} from 'react-native';
55
import type {FlatList, ListRenderItemInfo, NativeSyntheticEvent, StyleProp, ViewStyle, ViewToken} from 'react-native';
6-
import {useOnyx} from 'react-native-onyx';
76
import Animated from 'react-native-reanimated';
87
import type {FlatListPropsWithLayout} from 'react-native-reanimated';
98
import Checkbox from '@components/Checkbox';
@@ -29,7 +28,6 @@ import {isMobileChrome} from '@libs/Browser';
2928
import {addKeyDownPressListener, removeKeyDownPressListener} from '@libs/KeyboardShortcut/KeyDownPressListener';
3029
import variables from '@styles/variables';
3130
import CONST from '@src/CONST';
32-
import ONYXKEYS from '@src/ONYXKEYS';
3331

3432
type SearchListItem = TransactionListItemType | ReportListItemType | ReportActionListItemType;
3533
type SearchListItemComponentType = typeof TransactionListItem | typeof ChatListItem | typeof ReportListItem;
@@ -127,8 +125,6 @@ function SearchList(
127125
// Keep track of the number of selected items to determine if we should turn off selection mode
128126
const selectionRef = useRef(0);
129127

130-
const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
131-
132128
useEffect(() => {
133129
selectionRef.current = selectedItemsLength;
134130

@@ -315,23 +311,10 @@ function SearchList(
315311
}}
316312
shouldPreventDefaultFocusOnSelectRow={shouldPreventDefaultFocusOnSelectRow}
317313
queryJSONHash={queryJSONHash}
318-
policies={policies}
319314
/>
320315
);
321316
},
322-
[
323-
ListItem,
324-
canSelectMultiple,
325-
focusedIndex,
326-
handleLongPressRow,
327-
itemsToHighlight,
328-
onCheckboxPress,
329-
onSelectRow,
330-
policies,
331-
queryJSONHash,
332-
setFocusedIndex,
333-
shouldPreventDefaultFocusOnSelectRow,
334-
],
317+
[ListItem, canSelectMultiple, focusedIndex, handleLongPressRow, itemsToHighlight, onCheckboxPress, onSelectRow, queryJSONHash, setFocusedIndex, shouldPreventDefaultFocusOnSelectRow],
335318
);
336319

337320
return (

src/components/SelectionList/ChatListItem.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ function ChatListItem<TItem extends ListItem>({
2222
onFocus,
2323
onLongPressRow,
2424
shouldSyncFocus,
25-
policies,
2625
}: ChatListItemProps<TItem>) {
2726
const reportActionItem = item as unknown as ReportActionListItemType;
2827
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportActionItem?.reportID ?? CONST.DEFAULT_NUMBER_ID}`);
@@ -88,7 +87,6 @@ function ChatListItem<TItem extends ListItem>({
8887
CONST.REPORT.ACTIONS.TYPE.FORWARDED,
8988
].some((type) => type === reportActionItem.actionName)
9089
}
91-
policies={policies}
9290
/>
9391
</BaseListItem>
9492
);

src/components/SelectionList/types.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ import type {
1212
TextStyle,
1313
ViewStyle,
1414
} from 'react-native';
15-
import type {OnyxCollection} from 'react-native-onyx';
1615
import type {AnimatedStyle} from 'react-native-reanimated';
1716
import type {SearchRouterItem} from '@components/Search/SearchAutocompleteList';
1817
import type {SearchColumnType} from '@components/Search/types';
1918
import type {BrickRoad} from '@libs/WorkspacesSettingsUtils';
2019
// eslint-disable-next-line no-restricted-imports
2120
import type CursorStyles from '@styles/utils/cursor/types';
2221
import type CONST from '@src/CONST';
23-
import type {Policy} from '@src/types/onyx';
2422
import type {Attendee} from '@src/types/onyx/IOU';
2523
import type {Errors, Icon, PendingAction} from '@src/types/onyx/OnyxCommon';
2624
import type {SearchPersonalDetails, SearchReport, SearchReportAction, SearchTransaction} from '@src/types/onyx/SearchResults';
@@ -367,9 +365,6 @@ type ReportListItemProps<TItem extends ListItem> = ListItemProps<TItem> & {
367365

368366
type ChatListItemProps<TItem extends ListItem> = ListItemProps<TItem> & {
369367
queryJSONHash?: number;
370-
371-
/** The policies which the user has access to */
372-
policies?: OnyxCollection<Policy>;
373368
};
374369

375370
type ValidListItem =

src/pages/home/report/PureReportActionItem.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import mapValues from 'lodash/mapValues';
33
import React, {memo, useCallback, useContext, useEffect, useMemo, useRef, useState} from 'react';
44
import type {GestureResponderEvent, TextInput} from 'react-native';
55
import {InteractionManager, Keyboard, View} from 'react-native';
6-
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
6+
import type {OnyxEntry} from 'react-native-onyx';
77
import type {ValueOf} from 'type-fest';
88
import type {Emoji} from '@assets/emojis/types';
99
import {AttachmentContext} from '@components/AttachmentContext';
@@ -331,9 +331,6 @@ type PureReportActionItemProps = {
331331

332332
/** A message related to a report action that has been automatically forwarded */
333333
reportAutomaticallyForwardedMessage?: string;
334-
335-
/** Policies */
336-
policies?: OnyxCollection<OnyxTypes.Policy>;
337334
};
338335

339336
// This is equivalent to returning a negative boolean in normal functions, but we can keep the element return type
@@ -405,7 +402,6 @@ function PureReportActionItem({
405402
dismissTrackExpenseActionableWhisper = () => {},
406403
userBillingFundID,
407404
reportAutomaticallyForwardedMessage,
408-
policies,
409405
}: PureReportActionItemProps) {
410406
const {translate} = useLocalize();
411407
const {shouldUseNarrowLayout} = useResponsiveLayout();
@@ -1239,7 +1235,6 @@ function PureReportActionItem({
12391235
hasBeenFlagged={
12401236
![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === moderationDecision) && !isPendingRemove(action)
12411237
}
1242-
policies={policies}
12431238
>
12441239
{content}
12451240
</ReportActionItemSingle>

src/pages/home/report/ReportActionItemSingle.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, {useCallback, useMemo} from 'react';
22
import type {StyleProp, ViewStyle} from 'react-native';
33
import {View} from 'react-native';
4-
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
4+
import type {OnyxEntry} from 'react-native-onyx';
55
import Avatar from '@components/Avatar';
66
import {FallbackAvatar} from '@components/Icon/Expensicons';
77
import MultipleAvatars from '@components/MultipleAvatars';
@@ -39,7 +39,7 @@ import {
3939
import CONST from '@src/CONST';
4040
import ONYXKEYS from '@src/ONYXKEYS';
4141
import ROUTES from '@src/ROUTES';
42-
import type {Policy, Report, ReportAction} from '@src/types/onyx';
42+
import type {Report, ReportAction} from '@src/types/onyx';
4343
import type {Icon} from '@src/types/onyx/OnyxCommon';
4444
import type ChildrenProps from '@src/types/utils/ChildrenProps';
4545
import ReportActionItemDate from './ReportActionItemDate';
@@ -72,9 +72,6 @@ type ReportActionItemSingleProps = Partial<ChildrenProps> & {
7272

7373
/** If the action is being actived */
7474
isActive?: boolean;
75-
76-
/** Policies */
77-
policies?: OnyxCollection<Policy>;
7875
};
7976

8077
const showUserDetails = (accountID: number | undefined) => {
@@ -99,7 +96,6 @@ function ReportActionItemSingle({
9996
iouReport,
10097
isHovered = false,
10198
isActive = false,
102-
policies,
10399
}: ReportActionItemSingleProps) {
104100
const theme = useTheme();
105101
const styles = useThemeStyles();
@@ -111,10 +107,9 @@ function ReportActionItemSingle({
111107
const ownerAccountID = iouReport?.ownerAccountID ?? action?.childOwnerAccountID;
112108
const isReportPreviewAction = action?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW;
113109
const actorAccountID = getReportActionActorAccountID(action, iouReport, report, delegatePersonalDetails);
114-
const invoiceReceiverPolicy =
115-
report?.invoiceReceiver && 'policyID' in report.invoiceReceiver
116-
? policies?.[`${ONYXKEYS.COLLECTION.POLICY}${report.invoiceReceiver.policyID}`]
117-
: policies?.[`${ONYXKEYS.COLLECTION.POLICY}${CONST.DEFAULT_NUMBER_ID}`];
110+
const [invoiceReceiverPolicy] = useOnyx(
111+
`${ONYXKEYS.COLLECTION.POLICY}${report?.invoiceReceiver && 'policyID' in report.invoiceReceiver ? report.invoiceReceiver.policyID : CONST.DEFAULT_NUMBER_ID}`,
112+
);
118113

119114
let displayName = getDisplayNameForParticipant({accountID: actorAccountID, personalDetailsData: personalDetails});
120115
const {avatar, login, pendingFields, status, fallbackIcon} = personalDetails?.[actorAccountID ?? CONST.DEFAULT_NUMBER_ID] ?? {};

0 commit comments

Comments
 (0)