I confess, I have no real idea how to make your code work. I learned a very different way to achieve these ends from Jongware:
app.menus.item(“Character Style Panel Menu”).menuItems.item(“Select All Unused”).associatedMenuAction.invoke();
app.menus.item(“Character Style Panel Menu”).menuItems.item(“Delete Styles...”).associatedMenuAction.invoke();
Don't know if it will still work all these years later, but it will respect all charstyles used only in bullet definitions as used. That's what you're trying to do, right? You're using myDocument.findText() to see if a character style is applied to anything in the document (so you can delete it if unused), but that findText won't find a charstyle used only in a paragraph style, correct? So that's why you're looking specifically for charstyles used in this way?
If I have all that right, then I think you can safely rely on "Select All Unused." If I'm wrong, can you tell me where?