You've got it basically right but there are some wrinkles around the in-plan mega backdoor.
The treatment of Roth 401(k) money rolled into a Roth IRA is spelled out in
26 CFR § 1.408A-10. See Question 3 in that link for how the Roth 401(k) rollover fits in with the Roth IRA ordering rules. While the Roth IRA has three separate categories for withdrawing (contributions, conversions, earnings), this regulation doesn't put any portion of your rollover into the "conversions" bucket. Instead anything considered "investment in the contract" goes into the "contributions" category of your IRA and everything else goes in earnings. "Investment in the contract" for this purpose is defined in answer 6
here as the part of your rollover that wouldn't count as income if it were a withdrawal rather than a rollover. The consequence of this is that your in-plan mega backdoor conversion (but not the post-conversion earnings) will go into your Roth IRA contributions bucket, skipping ahead of any conversions that may be in your Roth IRA already such as from the regular backdoor.
An astute reader might look at the above paragraph and notice a potential loophole: if in-plan conversions go directly into the Roth IRA contributions bucket upon being rolled over, what's to stop you from converting a bunch of pre-tax money to Roth in your 401(k) and then rolling it into your Roth IRA where it could be immediately withdrawn without a 10% early withdrawal penalty? The answer is there's a "
special recapture rule" that applies the 10% early withdrawal tax to distributions of taxable in-plan rollovers within five years. This rule does not apply to withdrawals that are rolled over to your IRA, but it
does apply to withdrawals of this money from your Roth IRA within five years after the in-plan conversion.
A question I have about the above, but have never found the answer to, is how is this special recapture rule applied when you only withdraw part of your Roth IRA contributions bucket before the five-year clock expires?
Suppose you have a Roth IRA with $25k in the contributions bucket pre-rollover. You roll a $100k Roth 401(k) into your Roth IRA, of which $50k is "investment in the contract" and $10k of that is subject to the five-year special recapture rule. Now you have $75k in the contributions bucket of your IRA, of which $10k is subject to the special recapture rule. If you withdraw the whole $75k it's pretty clear that you would be subject to a $1,000 ($10,000 * 10%) tax due to the special recapture rule. What happens if you only withdraw $25k? Maybe it's prorated and you owe $333, or maybe it's considered front-loaded and you owe the whole $1,000, or maybe it's back-loaded and you don't owe anything. I could see a certain logic behind any of these three possibilities, but have never seen a definitive source for which is the correct treatment.
To avoid this mess I suggest keeping the amount subject to this recapture rule to a minimum. Perform your mega backdoor conversions as soon after your paychecks as you reasonably can do, so that there's little to no growth between the contribution and the conversion. That way instead of having potentially thousands of dollars subject to the special recapture rule, it would be a much less significant number.