I read this article: https://overreacted.io/goodbye-clean-code/
I have a tendency to write dirty/ugly code almost always. I tend to go for simple stupid. Mainly with the thought that I will need to work on it at 2:00 am after no sleep.
There is a spot where cleaning up code makes sense. Usually if I have some number (2 or more) of the same code I start looking to bring it together. Even then it is a judgement call.
Sometimes it is pain based development. Does having 2 copies of this code cause me pain? Or have I put bugs in PROD because of the duplication? Then I should look to simplify the code.
One other thing from the article that you can learn is always talk to a maintainer if you are removing duplicated code. There might be reasons it is there. They may love your changes too. Be polite and ask.