Similar to the call exceptions, we can specify whether SMS/MMS messages or messages via messaging apps, such as WhatsApp, should be allowed in Do Not Disturb mode.

We can also choose to allow all contacts or contact favourites.

The messages from allowed contacts will then be put through with sound and vibration.

Android 10 | OxygenOS 10.0
Allow messages -  Open the  Settings
Allow messages -  Tap on  Sounds & vibration
Allow messages -  Tap on  Do Not Disturb
Allow messages -  Tap on  SMS, MMS, and messaging apps
Allow messages -  Tap on  Allow messages
Allow messages -  Choose  From anyone ,  From contacts only ,  From starred contacts only  or  Don´t allow any messages
  1. Open the Settings
  2. Tap on Sounds & vibration
  3. Tap on Do Not Disturb
  4. Tap on SMS, MMS, and messaging apps
  5. Tap on Allow messages
  6. Choose From anyoneFrom contacts only, From starred contacts only or Don´t allow any messages

OnePlus Instructions