>> I explained to that I was cleaning up a ton of technical debt and that's why it was taking so long.
> The only point here that jumps at me is that the manager came a few weeks to late to explain the development values.
Well...(and I'm not having a go at rsweeney21). They were asked to implement a feature, not to spend ages cleaning up technical debt, and being "was still weeks away from being done" would be an alarm bell for me as a senior dev/manager. If the feature couldn't ever possibly be implemented due to technical debt then GP should have raised this with their manager far earlier rather than just going ahead and fixing this silently. If the feature can be developed and released, despite technical dept, then go ahead and point out to your manager (as soon as possible) this is going to be horrible for the dev(s) working on the next iteration, but the chances are your manager will likely insist you get on with the feature. Communication is at fault here.
We all work in projects that have technical debt and we'd all love to go back and fix these things. But you also have that obvious tension which is the fact that you also need to release features which have been identified by the business as another positive cash-income thing because you're competing against other services - and sometimes these features are very time critical.
Sounds like GP poster seems reasonably experienced (working at MS, Netflix) and should probably know this (unless there are other mitigating factors not included in your comment)
Yeah, I feel like this one was on me. I was new to the job and wanted to impress my manager. I could feel the refactoring getting out of hand. I should have had a conversation with my manager to ensure I was going in the right direction before he felt the need to tell me I was taking too long.
Don't be too hard on yourself; it takes two to tango. You are your manager's work, as much as your code is yours. Unless you lied about progress it's a miscommunication with no right or wrong.