Cities aren’t black holes that cause all job locations to collapse into a singularity. If density were allowed to grow you’d find jobs appearing in other places (and the biggest cities have this already - the jobs aren’t only in the central metro area).
We have the technology to stack dwellings on top of each other. If commute times become unreasonable we also have the technology to reduce it, with trams or rail. Even better build the commute infrastructure first and then the housing but Singapore and Manhattan show pretty clearly what’s possible. Shanghai didn’t have a metro system 20 years ago. Now it’s the world's biggest.
But that is what falls into "affordable housing" category. Comment I reacted to said it is not needed, because people move.
It doesn't all fall into affordable housing category, people are complaining in London about new luxury high rise apartments because they are high end and "not affordable".