diff --git a/tests/filtered_relation/tests.py b/tests/filtered_relation/tests.py
index 2cceeb82e7..f74e3978f9 100644
--- a/tests/filtered_relation/tests.py
+++ b/tests/filtered_relation/tests.py
@@ -11,8 +11,10 @@ from django.db.models import (
     FilteredRelation,
     Q,
     Sum,
+    Value,
     When,
 )
+from django.db.models.functions import Concat
 from django.test import TestCase
 from django.test.testcases import skipUnlessDBFeature
 
@@ -629,6 +631,26 @@ class FilteredRelationTests(TestCase):
                 ),
             )
 
+    def test_condition_with_exact_lookup_outside_relation_name(self):
+        qs = Author.objects.annotate(
+            book_editor=FilteredRelation(
+                "book__editor",
+                condition=Q(book__author__name="book"),
+            ),
+        ).filter(book_editor__isnull=True)
+        self.assertEqual(qs.count(), 4)
+
+    def test_condition_with_func_and_lookup_outside_relation_name(self):
+        qs = Author.objects.annotate(
+            book_editor=FilteredRelation(
+                "book__editor",
+                condition=Q(
+                    book__title=Concat(Value("The book by "), F("book__author__name"))
+                ),
+            ),
+        ).filter(book_editor__isnull=False)
+        self.assertEquals(qs.count(), 1)
+
     def test_condition_deeper_relation_name(self):
         msg = (
             "FilteredRelation's condition doesn't support nested relations "