Does the 5 year rule apply on the After-tax 401k -> Roth 401k -> Roth
IRA conversion of the 20000 (including 10000 earnings that was
originally pre-tax)?
No. The after-tax amounts are not subject to the 5 years rule. The earnings are.
How does this affect Roth IRA withdrawal ordering rules with respect
to the taxable portion of a single conversion being withdrawn before
the non-taxable portion?
Taxable portion first until exhausted.
To better understand how it works, you need to understand the rationale behind the 5-year rule.
Consider you have $100K in your IRA (traditional) and you want to take it out. Just withdrawing it would trigger a 10K statutory penalty, on top of the taxes due. But, you can use the backdoor Roth IRA, right? So convert the 100K, and then it becomes after-tax contribution to Roth IRA, and can be withdrawn with no penalty. One form filled ad 10K saved.
To block this loophole, here comes the 5 years rule: you cannot withdraw after-tax amounts for at least 5 years without penalty, if the source was taxable conversion. Thus, in order to avoid the 10K penalty in the above situation, you have a 5-year cooling period, which makes the loophole useless for most cases.
However amounts that are after tax can be withdrawn without penalty already, even from the traditional IRA, so there's no need in the 5 years cooling period.
The withdrawal attribution is in this order:
- Roth IRA contributions
- Conversions and rollovers (excluding Roth IRA rollovers), starting with the earliest, taxable portion first
- Earnings
Roth IRA rollovers are sourced to the origin. E.g.: if you converted $100 to the Roth IRA at firm X and then a year later rolled it over to firm Y - it doesn't affect anything and the clock is ticking from the original date of the conversion at firm X.
5-year period applies to each conversion/rollover from a qualified retirement plan (see here). Distributions are applied to the conversions in FIFO order, so in one distribution, depending on the amounts, you may hit several different incoming conversions. The 5 years should be check on each of them, and the penalty applied on the amounts attributable to those that don't have enough time.
5-year period for contributions applies starting from the beginning of the first year of the first contribution that established your Roth IRA plan.
The penalty applies to the amounts that were included in your gross income when conversion occurred, i.e.: doesn't apply on the amounts converted from after-tax sources.
Note the difference from the traditional IRA - distributions from pre-tax sources are prorated between the non-deductible (basis) amounts and the deductible/earnings amounts (taxable). That is why the taxable amounts are first in the ordering of the distributions.