I had a similar issue, when implementing templates for a custom block in Drupal 10.1. I propose here two important lessons I have learnt while solving it.
Matching (some) strings
Theme name, which is ...
My use case was, that I had a leftover menu link, when uninstalling the CAS module, due to this core issue https://www.drupal.org/project/drupal/issues/3324291. Since I could not load the menu link ...
Based on the context you provided I would suggest going for an Abstract class or a Trait.
I try to answer this questions when I doubt:
Does doSomethingCommon() relys ...
While doing this I updated the htaccess file and drupal's settings.php
to make sure references to the root directory
There is nothing to do in these files or others to change the directory from where ...