The key is that the solo 401k plan uses separate bank or brokerage accounts to track each fund sources:
Solo 401k Allows for All Three Contribution Sources: Solo 401k palns allows for all three contribution sources (i.e.g, pretax, roth and voluntary after-tax). The rules require each source to be separately tracked. The solo 401k provider will assist with the set up of the bank/ brokerage. The following pages cover the differences and similarities between each source. https://www.mysolo401k.net/roth-solo-401k-contributions-vs-voluntary-after-tax-solo-401k-contributions/
Illustration:
Sally opened a solo 401k plan with a solo 401k plan provider whose documents allow for all three contribution types described above including voluntary after-tax contributions. Sally opens up three sperate brokerage accounts under the solo 401k plan--a separate one for each source of funds. She makes a voluntary after-tax contribution of $50,000 to her solo 401k, with the funds deposited in the dedicated brokerage account under the solo 401k plan to just hold voluntary after tax funds. She then elects to have her full voluntary after-tax solo 401k balance including earnings (e.g., $550) to her Roth IRA and traditional IRA so that the breakdown is as follows:
The basis ($50,000) gets converted tax free to her Roth IRA, and the $550 earnings gets transferred/directly rolled over tax free to her traditional IRA.