Full site editing templates folder vs block-templates

After some more checking, I found the issue. The repo I was setting up, was a template that will be used by other sites, so I saved it in a folder called templates (Full path: /Users/bas/git/work/templates/wp). In the wp-includes/block-template-utils.php the name/slug of the template is decided with the following code.

$template_slug = substr(
  // Starting position of slug.
  strpos($template_file, $template_base_path . DIRECTORY_SEPARATOR) + 1 + strlen($template_base_path),
  // Subtract ending '.html'.

$template_base_path is templates in the Twenty-TwentyThree theme, so it split it on the first occurrence of templates which was a lot earlier in the string (see the full path). If I moved my repo to /Users/bas/git/work/template/wp it all works since the string is splitted correctly.