"Use a progress indicator for any action that takes longer than about 1.0 second."
https://www.nngroup.com/articles/progress-indicators/
You don't necessarily know in advance whether it'll take 1 second, but I think a strategy that would work is: after 1 second, if the task is not done, open a progress bar, and if the task completes immediately after that, display the completed progress bar for 500 milliseconds or something before closing it.
Maybe the really inexperienced users, but it makes sense that something which happens quickly, will mean a window that also appears and disappears quickly. This is why Windows has options to disable animations and other effects, and everything does feel noticeably more responsive when they are disabled --- windows and menus appear and disappear instantly.
I think it comes down to good UI+UX, which in this particular case becomes bad UI+UX.