diff --git a/src/components/views/right_panel/UserInfo.tsx b/src/components/views/right_panel/UserInfo.tsx
index b2587fe539..a339a1ebce 100644
--- a/src/components/views/right_panel/UserInfo.tsx
+++ b/src/components/views/right_panel/UserInfo.tsx
@@ -521,7 +521,8 @@ export const UserOptionsSection: React.FC<{
);
- const directMessageButton = isMe ? null : ;
+ const directMessageButton =
+ isMe || !shouldShowComponent(UIComponent.CreateRooms) ? null : ;
return (
diff --git a/test/components/views/right_panel/UserInfo-test.tsx b/test/components/views/right_panel/UserInfo-test.tsx
index eddba91f6a..4be9c4b6a9 100644
--- a/test/components/views/right_panel/UserInfo-test.tsx
+++ b/test/components/views/right_panel/UserInfo-test.tsx
@@ -62,6 +62,8 @@ import { E2EStatus } from "../../../../src/utils/ShieldUtils";
import { DirectoryMember, startDmOnFirstMessage } from "../../../../src/utils/direct-messages";
import { clearAllModals, flushPromises } from "../../../test-utils";
import ErrorDialog from "../../../../src/components/views/dialogs/ErrorDialog";
+import { shouldShowComponent } from "../../../../src/customisations/helpers/UIComponents";
+import { UIComponent } from "../../../../src/settings/UIFeature";
jest.mock("../../../../src/utils/direct-messages", () => ({
...jest.requireActual("../../../../src/utils/direct-messages"),
@@ -88,6 +90,13 @@ jest.mock("../../../../src/utils/DMRoomMap", () => {
};
});
+jest.mock("../../../../src/customisations/helpers/UIComponents", () => {
+ const original = jest.requireActual("../../../../src/customisations/helpers/UIComponents");
+ return {
+ shouldShowComponent: jest.fn().mockImplementation(original.shouldShowComponent),
+ };
+});
+
const defaultRoomId = "!fkfk";
const defaultUserId = "@user:example.com";
const defaultUser = new User(defaultUserId);
@@ -325,6 +334,33 @@ describe("", () => {
// will not return true, so we expect to see the noCommonMethod error from VerificationPanel
expect(screen.getByText(/try with a different client/i)).toBeInTheDocument();
});
+
+ it("renders the message button", () => {
+ render(
+
+
+ ,
+ );
+
+ screen.getByRole("button", { name: "Message" });
+ });
+
+ it("hides the message button if the visibility customisation hides all create room features", () => {
+ mocked(shouldShowComponent).withImplementation(
+ (component) => {
+ return component !== UIComponent.CreateRooms;
+ },
+ () => {
+ render(
+
+
+ ,
+ );
+
+ expect(screen.queryByRole("button", { name: "Message" })).toBeNull();
+ },
+ );
+ });
});
describe("with crypto enabled", () => {