Skip to content
4 changes: 0 additions & 4 deletions src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ function mapTransactionItemToSelectedEntry(
undefined,
undefined,
outstandingReportsByPolicyID,
true,
),
action: item.action,
reportID: item.reportID,
Expand Down Expand Up @@ -180,7 +179,6 @@ function prepareTransactionsList(
undefined,
undefined,
outstandingReportsByPolicyID,
true,
),
action: item.action,
reportID: item.reportID,
Expand Down Expand Up @@ -435,7 +433,6 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS
undefined,
undefined,
outstandingReportsByPolicyID,
true,
),
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
isSelected: areAllMatchingItemsSelected || selectedTransactions[transaction.transactionID].isSelected,
Expand Down Expand Up @@ -467,7 +464,6 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS
undefined,
undefined,
outstandingReportsByPolicyID,
true,
),
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
isSelected: areAllMatchingItemsSelected || selectedTransactions[transaction.transactionID].isSelected,
Expand Down
10 changes: 5 additions & 5 deletions src/hooks/usePolicyForMovingExpenses.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import {activePolicySelector} from '@selectors/Policy';
import type {OnyxEntry} from 'react-native-onyx';
import {useSession} from '@components/OnyxListItemProvider';
import {getPolicyRole, isPaidGroupPolicy, isPolicyAdmin, isPolicyMemberWithoutPendingDelete, isPolicyUser} from '@libs/PolicyUtils';
import {isPaidGroupPolicy, isPolicyMemberWithoutPendingDelete} from '@libs/PolicyUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Policy} from '@src/types/onyx';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import useOnyx from './useOnyx';

// TODO: temporary util - if we don't have employeeList object we don't check for the pending delete
function checkForPendingDelete(login: string, policy: OnyxEntry<Policy>) {
function checkForUserPendingDelete(login: string, policy: OnyxEntry<Policy>) {
if (isEmptyObject(policy?.employeeList)) {
return true;
}
return isPolicyMemberWithoutPendingDelete(login, policy);
}

function isPolicyMemberByRole(login: string, policy: OnyxEntry<Policy>) {
return isPolicyAdmin(policy, login) || isPolicyUser(policy, login) || getPolicyRole(policy, login) === CONST.POLICY.ROLE.AUDITOR;
function isPolicyMemberByRole(policy: OnyxEntry<Policy>) {
return !!policy?.role && Object.values(CONST.POLICY.ROLE).includes(policy.role);
}

function usePolicyForMovingExpenses() {
Expand All @@ -32,7 +32,7 @@ function usePolicyForMovingExpenses() {
const login = session?.email ?? '';
const userPolicies = Object.values(allPolicies ?? {}).filter(
(policy) =>
checkForPendingDelete(login, policy) && isPolicyMemberByRole(login, policy) && isPaidGroupPolicy(policy) && policy?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
checkForUserPendingDelete(login, policy) && isPolicyMemberByRole(policy) && isPaidGroupPolicy(policy) && policy?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
);
const isMemberOfMoreThanOnePolicy = userPolicies.length > 1;

Expand Down
4 changes: 1 addition & 3 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@

let conciergeReportID: OnyxEntry<string>;
Onyx.connect({
key: ONYXKEYS.CONCIERGE_REPORT_ID,

Check warning on line 931 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
callback: (value) => {
conciergeReportID = value;
},
Expand All @@ -936,7 +936,7 @@

const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon';
Onyx.connect({
key: ONYXKEYS.SESSION,

Check warning on line 939 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
callback: (value) => {
// When signed out, val is undefined
if (!value) {
Expand All @@ -954,7 +954,7 @@
let allPersonalDetailLogins: string[];
let currentUserPersonalDetails: OnyxEntry<PersonalDetails>;
Onyx.connect({
key: ONYXKEYS.PERSONAL_DETAILS_LIST,

Check warning on line 957 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
callback: (value) => {
if (currentUserAccountID) {
currentUserPersonalDetails = value?.[currentUserAccountID] ?? undefined;
Expand All @@ -966,14 +966,14 @@

let allReportsDraft: OnyxCollection<Report>;
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT_DRAFT,

Check warning on line 969 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
waitForCollectionCallback: true,
callback: (value) => (allReportsDraft = value),
});

let allPolicies: OnyxCollection<Policy>;
Onyx.connect({
key: ONYXKEYS.COLLECTION.POLICY,

Check warning on line 976 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
waitForCollectionCallback: true,
callback: (value) => (allPolicies = value),
});
Expand All @@ -981,7 +981,7 @@
let allReports: OnyxCollection<Report>;
let reportsByPolicyID: ReportByPolicyMap;
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,

Check warning on line 984 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
waitForCollectionCallback: true,
callback: (value) => {
allReports = value;
Expand Down Expand Up @@ -1024,14 +1024,14 @@
Onyx.connect({
key: ONYXKEYS.BETAS,
callback: (value) => (allBetas = value),
});

Check warning on line 1027 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function

let allTransactions: OnyxCollection<Transaction> = {};
let reportsTransactions: Record<string, Transaction[]> = {};
Onyx.connect({
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {

Check warning on line 1034 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
if (!value) {
return;
}
Expand All @@ -1057,7 +1057,7 @@
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {

Check warning on line 1060 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
if (!actions) {
return;
}
Expand All @@ -1070,7 +1070,7 @@
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT_METADATA,
waitForCollectionCallback: true,
callback: (value) => {

Check warning on line 1073 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
if (!value) {
return;
}
Expand Down Expand Up @@ -4303,8 +4303,6 @@
isDeleteAction?: boolean,
isChatReportArchived = false,
outstandingReportsByPolicyID?: OutstandingReportsByPolicyIDDerivedValue,
// TODO: [Unreported Expense project] temporary check for Search Page only, remove it when no longer necessary
isSearchPageOption?: boolean,
): boolean {
// A list of fields that cannot be edited by anyone, once an expense has been settled
const restrictedFields: string[] = [
Expand Down Expand Up @@ -4391,7 +4389,7 @@

const isUserWorkspaceMember = getActivePolicies(allPolicies ?? {}, currentUserEmail).filter((userPolicy) => isPaidGroupPolicyPolicyUtils(userPolicy)).length;

if (isUnreportedExpense && isSearchPageOption && isUserWorkspaceMember) {
if (isUnreportedExpense && isUserWorkspaceMember) {
return true;
}

Expand Down
3 changes: 2 additions & 1 deletion src/pages/NewReportWorkspaceSelectionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ function NewReportWorkspaceSelectionPage({route}: NewReportWorkspaceSelectionPag
);
if (selectedTransactionIDs.length) {
clearSelectedTransactions(true);
} else if (selectedTransactionsKeys.length) {
}
if (selectedTransactionsKeys.length) {
clearSelectedTransactions();
}
Navigation.dismissModal();
Expand Down
4 changes: 2 additions & 2 deletions src/pages/iou/request/step/IOURequestEditReportCommon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function IOURequestEditReportCommon({
const headerMessage = useMemo(() => (searchValue && !reportOptions.length ? translate('common.noResultsFound') : ''), [searchValue, reportOptions, translate]);

const createReportOption = useMemo(() => {
if (!createReport || isUnreported) {
if (!createReport) {
return undefined;
}

Expand All @@ -164,7 +164,7 @@ function IOURequestEditReportCommon({
icon={Expensicons.DocumentPlus}
/>
);
}, [createReport, isUnreported, translate, policyForMovingExpenses?.name]);
}, [createReport, translate, policyForMovingExpenses?.name]);

// eslint-disable-next-line rulesdir/no-negated-variables
const shouldShowNotFoundPage = useMemo(() => {
Expand Down
Loading