Define terrible.
If said terrible code worked and meant the deadline was meant, depending on the situation, it might be unavoidable. I am not ashamed to admit I have been in this situation. If a company can't manage their timelines appropriately, promise clients unrealistic timelines or worse: underquote to pocket the cash, then what is the alternative?
I think we have all been in this situation before:
Boss/Project manager: the project is due in two weeks, you're a smart guy and John will help you. This is a great client and we really want to woo them. This will just be a one time thing, in future we will properly plan for projects like this.
Developer: Uh.. I don't think two weeks is achievable. If no changes are made and I get finalised designs, then we might be able to get it done.
Designer: I just have a few design tweaks I want to make, nothing major. I have just redesigned this page, changed the font and oh, we need to make it look good on small, medium and large screens as well.
Before you know it, you're leaving at 10pm every night. You're coming in at 7am and you're also working weekends to get the work done. Even if things aren't being changed (which in many situations, they are because others are under the pump as well), you'll be putting in serious overtime.
I personally know of companies who factor in overtime into their estimates. They deliberately promise delivery dates that cannot be met without overtime. It's shady, but a lot of companies do it. It's amazing what being in fear of losing your job can do. Sometimes nothing you say or do can change that, except finding somewhere else to work.
Sometimes even when you speak up, nothing changes because the decision has already been made without consulting you first, the client has been told a date already. If you work for a company that do client work like a studio that does Wordpress websites or apps, this situation is something you will encounter, some places more than others.