Can’t you use something like iMazing (I’m not a paid shill just a satisfied user and there are many similar other products from competitors) and do an offline dump from the backup?
Article mentions this: “...there’s a whole slew of third party tools that slurp up your iMessages, and Apple should care about this, because having a strong demand for apps that process users’ messages should be seen as a privacy failure by the company.”