diff --git a/changelog.d/8467.feature b/changelog.d/8467.feature
new file mode 100644
index 0000000000000000000000000000000000000000..6d0335e2c827fbb0ae34c121d405a27c2d0c2f86
--- /dev/null
+++ b/changelog.d/8467.feature
@@ -0,0 +1 @@
+Allow `ThirdPartyEventRules` modules to query and manipulate whether a room is in the public rooms directory.
\ No newline at end of file
diff --git a/synapse/events/third_party_rules.py b/synapse/events/third_party_rules.py
index fed459198a062cf66df8a2fcec67a415ac406963..1ca77519d59afc17bd2208f2b1bc1f6a6469f100 100644
--- a/synapse/events/third_party_rules.py
+++ b/synapse/events/third_party_rules.py
@@ -131,7 +131,9 @@ class ThirdPartyEventRules:
         if self.third_party_rules is None:
             return True
 
-        check_func = getattr(self.third_party_rules, "check_visibility_can_be_modified")
+        check_func = getattr(
+            self.third_party_rules, "check_visibility_can_be_modified", None
+        )
         if not check_func or not isinstance(check_func, Callable):
             return True
 
diff --git a/tests/rest/client/third_party_rules.py b/tests/rest/client/test_third_party_rules.py
similarity index 96%
rename from tests/rest/client/third_party_rules.py
rename to tests/rest/client/test_third_party_rules.py
index 715e87de082b59913ff33a097f12ecc7deba5f8b..7b322f526c8655416717702723aeda547995ae89 100644
--- a/tests/rest/client/third_party_rules.py
+++ b/tests/rest/client/test_third_party_rules.py
@@ -49,7 +49,7 @@ class ThirdPartyRulesTestCase(unittest.HomeserverTestCase):
     def make_homeserver(self, reactor, clock):
         config = self.default_config()
         config["third_party_event_rules"] = {
-            "module": "tests.rest.client.third_party_rules.ThirdPartyRulesTestModule",
+            "module": __name__ + ".ThirdPartyRulesTestModule",
             "config": {},
         }