Skip to content

Commit

Permalink
Merge pull request #35223 from bernhardoj/fix/34950-allow-policy-memb…
Browse files Browse the repository at this point in the history
…er-rename

Allow all policy member to rename room name
  • Loading branch information
youssef-lr authored Jan 29, 2024
2 parents d1f2e7c + 7783f14 commit ab395ee
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,7 @@ import CONST from '@src/CONST';
import type {ParentNavigationSummaryParams, TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {
Beta,
Login,
PersonalDetails,
PersonalDetailsList,
Policy,
PolicyReportField,
Report,
ReportAction,
ReportMetadata,
Session,
Transaction,
TransactionViolation,
} from '@src/types/onyx';
import type {Beta, PersonalDetails, PersonalDetailsList, Policy, PolicyReportField, Report, ReportAction, ReportMetadata, Session, Transaction, TransactionViolation} from '@src/types/onyx';
import type {Participant} from '@src/types/onyx/IOU';
import type {Errors, Icon, PendingAction} from '@src/types/onyx/OnyxCommon';
import type {ChangeLog, IOUMessage, OriginalMessageActionName, OriginalMessageCreated} from '@src/types/onyx/OriginalMessage';
Expand Down Expand Up @@ -453,12 +440,6 @@ Onyx.connect({
callback: (value) => (allPolicies = value),
});

let loginList: OnyxEntry<Login>;
Onyx.connect({
key: ONYXKEYS.LOGIN_LIST,
callback: (value) => (loginList = value),
});

let allTransactions: OnyxCollection<Transaction> = {};

Onyx.connect({
Expand Down Expand Up @@ -4210,9 +4191,8 @@ function shouldDisableRename(report: OnyxEntry<Report>, policy: OnyxEntry<Policy
return true;
}

// If there is a linked workspace, that means the user is a member of the workspace the report is in.
// Still, we only want policy owners and admins to be able to modify the name.
return !Object.keys(loginList ?? {}).includes(policy.owner) && policy.role !== CONST.POLICY.ROLE.ADMIN;
// If there is a linked workspace, that means the user is a member of the workspace the report is in and is allowed to rename.
return false;
}

/**
Expand Down

0 comments on commit ab395ee

Please sign in to comment.