Skip to content

Commit

Permalink
reduce diff
Browse files Browse the repository at this point in the history
  • Loading branch information
TMisiukiewicz committed Jul 31, 2024
1 parent e8df1c9 commit 2714eec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
18 changes: 9 additions & 9 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,15 @@ function isPolicyExpenseChatAdmin(report: OnyxEntry<Report>, policies: OnyxColle
return policyRole === CONST.POLICY.ROLE.ADMIN;
}

/**
* Checks if the current user is the admin of the policy.
*/
function isPolicyAdmin(policyID: string, policies: OnyxCollection<Policy>): boolean {
const policyRole = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]?.role;

return policyRole === CONST.POLICY.ROLE.ADMIN;
}

/**
* Checks whether all the transactions linked to the IOU report are of the Distance Request type with pending routes
*/
Expand All @@ -1435,15 +1444,6 @@ function hasOnlyTransactionsWithPendingRoutes(iouReportID: string | undefined):
return transactions.every((transaction) => TransactionUtils.isFetchingWaypointsFromServer(transaction));
}

/**
* Checks if the current user is the admin of the policy.
*/
function isPolicyAdmin(policyID: string, policies: OnyxCollection<Policy>): boolean {
const policyRole = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]?.role;

return policyRole === CONST.POLICY.ROLE.ADMIN;
}

/**
* If the report is a thread and has a chat type set, it is a workspace chat.
*/
Expand Down
14 changes: 1 addition & 13 deletions src/libs/TransactionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,7 @@ import Onyx from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {
Beta,
OnyxInputOrEntry,
Policy,
RecentWaypoint,
ReportAction,
ReviewDuplicates,
TaxRate,
TaxRates,
Transaction,
TransactionViolation,
TransactionViolations,
} from '@src/types/onyx';
import type {Beta, OnyxInputOrEntry, Policy, RecentWaypoint, ReviewDuplicates, TaxRate, TaxRates, Transaction, TransactionViolation, TransactionViolations} from '@src/types/onyx';
import type {Comment, Receipt, TransactionChanges, TransactionPendingFieldsKey, Waypoint, WaypointCollection} from '@src/types/onyx/Transaction';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import type {IOURequestType} from './actions/IOU';
Expand Down

0 comments on commit 2714eec

Please sign in to comment.