Transferring the beer from the primary fermenter to a secondary vessel runs a few risks.
If you aren't doing a closed transfer you will add oxygen to the beer. This will speed up the staling of the beer, especially the more volatile compounds, like hop compounds. The transfer can also add microbes that could change the flavour of the beer. The oxygen effect is guaranteed without a closed transfer. The microbial infection one is far less common. These two are risks regardless of whether fermentation is nearly finished or completed.
If you're transferring before the end of fermentation I can see one big risk that can bite for a number of different reasons. It's not transferring enough yeast to finish off the fermentation. This would be especially relevant if you're dry hopping or adding fruit in the secondary container. Though sometimes your beer could just stall near the end and being able to rouse the dormant yeast out of the yeast cake can help you finish it off.
Turning the question on it's head, what's the risks of leaving the beer on the yeast cake? That you'll have enough dead yeast cells that it will change the flavour of the beer. That's the only one I know. And that's more a function of how stressed the yeast got during the fermentation than how long you wait.
Plenty of healthy yeast starting the fermentation will leave a small number of dead yeast cells and a large number of dormant yeast cells in the yeast cake. Time will slowly change that ratio after fermentation, but relatively healthy yeast will stay dormant for months.
So assuming an adequate pitch of healthy yeast cells you've got at least a month, if not multiple months before you'll taste dead yeast cells. Underpitching in to a high gravity wort and the taste threshold will be met much earlier. I've certainly left some of mine for multiple months without noticing that yeast extract flavour.
The yeast cake does contain other compounds that can change the flavour of the beer, but managing those is more related to not transferring them out of the fermenter rather than the amount of time the beer sits on them. You should always aim to disturb the yeast cake as little as possible when transferring out of the fermenter. People will often cold crash the beer to make sure all that can drop to the bottom of the fermenter does drop before transfer, though that's also another way to introduce oxygen into the beer.