Tax on RMD

In 2022 I retired at age 78 and took my first RMD. The total RMD based on my age and the amount in my 401k plan on 12/31/21 was correctly calculated and included in Box 1, Gross Distribution on the 1099-R form I received from Fidelity.

My 401K consists of three buckets:

1. Pre tax deferrals plus earnings

2. Voluntary after tax deferrals plus earnings

3. Roth contributions and earnings--my 401k plan allowed me to make voluntary after-tax contributions to a Roth bucket that is included in the 401k plan. Of course I paid the tax on the Roth deferrals when they were made.

My understanding is that the total RMD needs to include all components of my 401K. But I also think that in so far as a significant portion of my 401k consists of after-tax deferrals and Roth deferrals (and earnings), that the fraction of the total calculated RMD generated by these after-tax buckets should be deducted from the 1099-R gross distribution so as to not be taxable.  Am I correct?   

Thank you in advance.