Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/ReportWelcomeText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) {
{report?.invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.INDIVIDUAL ? (
<Text style={[styles.textStrong]}>{getDisplayNameForParticipant({accountID: report?.invoiceReceiver?.accountID})}</Text>
) : (
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
<Text style={[styles.textStrong]}>{getPolicy(report?.invoiceReceiver?.policyID)?.name}</Text>
)}
</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/libs/CardFeedUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ function getWorkspaceCardFeedData(cardFeed: WorkspaceCardsList | undefined, repe
const {domainName, bank} = representativeCard;
const isBankRepeating = repeatingBanks.includes(bank);
const policyID = domainName.match(CONST.REGEX.EXPENSIFY_POLICY_DOMAIN_NAME)?.[1] ?? '';
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
const correspondingPolicy = getPolicy(policyID?.toUpperCase());
const cardFeedLabel = isBankRepeating ? correspondingPolicy?.name : undefined;
const cardFeedBankName = bank === CONST.EXPENSIFY_CARD.BANK ? translate('search.filters.card.expensify') : getBankName(bank as CompanyCardFeed);
Expand Down
2 changes: 2 additions & 0 deletions src/libs/CardMessageUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ function getExpensifyCardFromReportAction({reportAction, policyID}: {reportActio
const cardID = cardIssuedActionOriginalMessage?.cardID ?? CONST.DEFAULT_NUMBER_ID;
const workspaceAccountID = getWorkspaceAccountID(policyID);
const allExpensifyCards = allWorkspaceCards?.[`cards_${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`] ?? {};
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
return isPolicyAdmin(getPolicy(policyID)) ? allExpensifyCards?.[cardID] : allUserCards[cardID];
}

Expand Down
2 changes: 2 additions & 0 deletions src/libs/DistanceRequestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ function getCustomUnitRateID(reportID?: string) {
}
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`];
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
const policy = getPolicy(report?.policyID ?? parentReport?.policyID);

if (isEmptyObject(policy)) {
Expand Down
2 changes: 2 additions & 0 deletions src/libs/PerDiemRequestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Onyx.connect({
function getCustomUnitID(reportID: string) {
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`];
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
const policy = getPolicy(report?.policyID ?? parentReport?.policyID);
let customUnitID: string = CONST.CUSTOM_UNITS.FAKE_P2P_ID;
let category: string | undefined;
Expand Down
20 changes: 19 additions & 1 deletion src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ function getAdminEmployees(policy: OnyxEntry<Policy>): PolicyEmployee[] {

/**
* Returns the policy of the report
* @deprecated Get the data straight from Onyx - This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
Comment thread
luacmartins marked this conversation as resolved.
*/
function getPolicy(policyID: string | undefined, policies: OnyxCollection<Policy> = allPolicies): OnyxEntry<Policy> {
if (!policies || !policyID) {
Expand Down Expand Up @@ -738,6 +739,8 @@ function hasPolicyWithXeroConnection(currentUserLogin: string | undefined) {

/** Whether the user can send invoice from the workspace */
function canSendInvoiceFromWorkspace(policyID: string | undefined): boolean {
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
const policy = getPolicy(policyID);
return policy?.areInvoicesEnabled ?? false;
}
Expand Down Expand Up @@ -1196,6 +1199,8 @@ function getCurrentTaxID(policy: OnyxEntry<Policy>, taxID: string): string | und
}

function getWorkspaceAccountID(policyID?: string) {
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
const policy = getPolicy(policyID);

if (!policy) {
Expand All @@ -1205,6 +1210,8 @@ function getWorkspaceAccountID(policyID?: string) {
}

function hasVBBA(policyID: string | undefined) {
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
const policy = getPolicy(policyID);
return !!policy?.achAccount?.bankAccountID;
}
Expand All @@ -1213,7 +1220,8 @@ function getTagApproverRule(policyOrID: string | SearchPolicy | OnyxEntry<Policy
if (!policyOrID) {
return;
}

// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
const policy = typeof policyOrID === 'string' ? getPolicy(policyOrID) : policyOrID;

const approvalRules = policy?.rules?.approvalRules ?? [];
Expand Down Expand Up @@ -1241,6 +1249,8 @@ function getAllPoliciesLength() {
}

function getActivePolicy(): OnyxEntry<Policy> {
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
return getPolicy(activePolicyId);
}

Expand Down Expand Up @@ -1278,6 +1288,8 @@ function getGroupPaidPoliciesWithExpenseChatEnabled(policies: OnyxCollection<Pol

// eslint-disable-next-line rulesdir/no-negated-variables
function shouldDisplayPolicyNotFoundPage(policyID: string): boolean {
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
const policy = getPolicy(policyID);

if (!policy) {
Expand Down Expand Up @@ -1306,6 +1318,8 @@ function canModifyPlan(policyID?: string) {
if (!policyID) {
return ownerPolicies.length > 1;
}
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
const policy = getPolicy(policyID);

return !!policy && isPolicyAdmin(policy);
Expand Down Expand Up @@ -1374,6 +1388,8 @@ const getDescriptionForPolicyDomainCard = (domainName: string): string => {
// A domain name containing a policyID indicates that this is a workspace feed
const policyID = domainName.match(CONST.REGEX.EXPENSIFY_POLICY_DOMAIN_NAME)?.[1];
if (policyID) {
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
const policy = getPolicy(policyID.toUpperCase());
return policy?.name ?? domainName;
}
Expand Down Expand Up @@ -1418,6 +1434,8 @@ export {
getNumericValue,
isMultiLevelTags,
getPersonalPolicy,
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
getPolicy,
getPolicyBrickRoadIndicatorStatus,
getPolicyEmployeeListByIdWithoutCurrentUser,
Expand Down
4 changes: 4 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2382,6 +2382,8 @@ function shouldShowAddMissingDetails(actionName?: ReportActionName, card?: Card)
}

function getJoinRequestMessage(reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_JOIN_REQUEST>) {
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
const policy = getPolicy(getOriginalMessage(reportAction)?.policyID);
const userDetail = getPersonalDetailByEmail(getOriginalMessage(reportAction)?.email ?? '');
const userName = userDetail?.firstName ? `${userDetail.displayName} (${userDetail.login})` : (userDetail?.login ?? getOriginalMessage(reportAction)?.email);
Expand Down Expand Up @@ -2411,6 +2413,8 @@ function getCardIssuedMessage({

const assigneeAccountID = cardIssuedActionOriginalMessage?.assigneeAccountID ?? CONST.DEFAULT_NUMBER_ID;
const cardID = cardIssuedActionOriginalMessage?.cardID ?? CONST.DEFAULT_NUMBER_ID;
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
const isPolicyAdmin = isPolicyAdminPolicyUtils(getPolicy(policyID));
const assignee = shouldRenderHTML ? `<mention-user accountID="${assigneeAccountID}"/>` : Parser.htmlToText(`<mention-user accountID="${assigneeAccountID}"/>`);
const navigateRoute = isPolicyAdmin ? ROUTES.EXPENSIFY_CARD_DETAILS.getRoute(policyID, String(cardID)) : ROUTES.SETTINGS_DOMAIN_CARD_DETAIL.getRoute(String(cardID));
Expand Down
Loading