In general, you should avoid full template overrides since they require maintenance - you have to run a diff and check what’s changed if a Discourse update breaks your theme.
What you can do, is take a step back and modify the data that gets passed to the template instead.
The topic-list-item is an ember component, so you can use api.modifyClass to make the changes you want
For example, here’s a snippet that will show the parent category badge in subcategory topics under the title. If the topic is in the main category, the code has no effect.
<script type="text/discourse-plugin" version="0.8">
const { on } = require("discourse-common/utils/decorators");
// parent category ids
const targetCategoryIds = [9, 15, 50];
const useParentCategory = function () {
const parentCategory = this.attrs.topic.category.parentCategory;
const switchToParent = parentCategory && targetCategoryIds.includes(parentCategory.id)
if (switchToParent) {
this.attrs.topic.set("category", parentCategory);
}
};
api.modifyClass("component:topic-list-item", {
@on("didReceiveAttrs")
setCategory() {
useParentCategory.call(this);
}
});
api.modifyClass("component:latest-topic-list-item", {
@on("didReceiveAttrs")
setCategory() {
useParentCategory.call(this);
}
});
</script>