Nobody cares about bad code if it works.
Besides you and your team, others don’t care about the bad code that exists in your codebase.
Management will not give you time to make the code better.
So don’t put it as a task on the board for the Product Owner to prioritize.
The PO will not care, ever.
But in the end, it is still your responsibility. You are the professional.
Every time you add a feature, add-on some time to do some refactoring. Don’t tell: Nobody cares.
Small refactoring’s will add up in time. Your codebase will be so much better in a years time.
Apply the Boy Scout Rule in coding: Leave the code better than you found it!