don't escape nested quotes inside t-string replacement fields (#5265)
diff --git a/CHANGES.md b/CHANGES.md
index 5c976f7..bcfe257 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -17,6 +17,10 @@
 
 <!-- Changes that affect Black's stable style -->
 
+- Fix unparseable output for a t-string whose replacement field contains a quote (for
+  example `t'\'{a["b"]}\''`). The guards that keep quote normalisation away from the
+  inside of an f-string replacement field were never reached for t-strings, so the
+  nested quotes were escaped and Black failed on its own output (#5265)
 - Fix unparseable output for a triple-quoted string whose body ends in an already
   escaped double quote (for example `'''\'''\"'''`). Switching to `"""` escaped the
   backslash instead of the quote, leaving the closing quotes bare, so Black failed on
diff --git a/src/black/linegen.py b/src/black/linegen.py
index 00ceb33..94f2714 100644
--- a/src/black/linegen.py
+++ b/src/black/linegen.py
@@ -615,7 +615,7 @@ def visit_tstring(self, node: Node) -> Iterator[Line]:
         if "\\" in string_leaf.value and any(
             "\\" in str(child)
             for child in node.children
-            if child.type == syms.fstring_replacement_field
+            if child.type == syms.tstring_replacement_field
         ):
             # string normalization doesn't account for nested quotes,
             # causing breakages. skip normalization when nested quotes exist
diff --git a/src/black/strings.py b/src/black/strings.py
index 89c7fab..4ce21c5 100644
--- a/src/black/strings.py
+++ b/src/black/strings.py
@@ -227,7 +227,7 @@ def normalize_string_quotes(s: str) -> str:
         new_body = sub_twice(escaped_orig_quote, rf"\1\2{orig_quote}", new_body)
         new_body = sub_twice(unescaped_new_quote, rf"\1\\{new_quote}", new_body)
 
-    if "f" in prefix.casefold():
+    if "f" in prefix.casefold() or "t" in prefix.casefold():
         matches = re.findall(
             r"""
             (?:(?<!\{)|^)\{  # start of the string or a non-{ followed by a single {
diff --git a/tests/data/cases/pep_750_nested_quotes.py b/tests/data/cases/pep_750_nested_quotes.py
new file mode 100644
index 0000000..d058376
--- /dev/null
+++ b/tests/data/cases/pep_750_nested_quotes.py
@@ -0,0 +1,34 @@
+# flags: --minimum-version=3.14
+# Regression test for t-strings whose replacement fields contain quotes.
+# Normalising the outer quotes would escape the inner ones and produce a
+# t-string that no longer parses, so these are left alone.
+x = t'\'{a["b"]}\''
+y = t'\'{"x"}\''
+# The same applies when the replacement field also carries a backslash.
+z = t'\'{a["\n"]}\''
+w = t'\'{"\n"}\''
+# A backslash in the replacement field stops normalisation on its own, so the
+# escaped quote in the literal part is kept as it is.
+v = t'{"\n"}\"'
+u = t'{a["\n"]}\"'
+# t-strings with nothing to escape are still normalised to double quotes.
+n = t'{a}'
+m = t'{a}\n'
+
+# output
+
+# Regression test for t-strings whose replacement fields contain quotes.
+# Normalising the outer quotes would escape the inner ones and produce a
+# t-string that no longer parses, so these are left alone.
+x = t'\'{a["b"]}\''
+y = t'\'{"x"}\''
+# The same applies when the replacement field also carries a backslash.
+z = t'\'{a["\n"]}\''
+w = t'\'{"\n"}\''
+# A backslash in the replacement field stops normalisation on its own, so the
+# escaped quote in the literal part is kept as it is.
+v = t'{"\n"}\"'
+u = t'{a["\n"]}\"'
+# t-strings with nothing to escape are still normalised to double quotes.
+n = t"{a}"
+m = t"{a}\n"