I did a mistake during an early refactor a year ago (the last refactor just before the code hit production, and any new update on models would demand a db migration), and i architectured and named a data structure poorly. Sadly it was a huge refactor on many part of the code, and we had a small team and few seniors, so the PR didn't catch the mistake.
I noticed an issue with a new feature i couldn't fix in a satisfactory manner monday. I talked a lot, with the lead and the other senior early. First i started doing a shitty fix. Then i asked for a carefull review from the other senior, we discussed the issue and managed to find the origin of all the bad code. Then i asked for more time (well, i "told" more than asked tbh) and did a full refactor, correct this time (hopefully) (the deployment + migration script will run next monday).
Writing bad code happen to everyone, at every company, especially when you don't have a lot of experience and domain knowledge. The issues appear when no one catch this bad code, or when people don't have the time or the latitude to fix it before it corrupt all the surrounding code.