I have a solution that I did a long time ago which you can try at your own risk. First make a backup of the following folder, maybe in a removable device to be on the safe side.
What you need:
Backup the following files from your user folder. Don't delete any folder beside instructed one. Library is hidden so press cmd+shift+. to make them visible. Use same button to revert it back
~/Library/Containers/com.apple.iChat
~/Library/Message
~/Library/Preferences -> Find all the files that contain the string "iChat" or
"iMessage"
Note: Kindly do this without being on the Internet from the start else iCloud from iPhone can sync with your MacBook later and you might get an issue.
Now as a crucial step:
~/Library/Containers/com.apple.iChat -> ~/Library/Containers/com.apple.iChat_old
~/Library/Message -> ~/Library/Message_old
But, Find all the files in ~/Library/Preferences that contain the string "iChat" or "iMessage" and CUT them into a separate folder or external HDD. Be sure to remember where you copied them from! Don't rename this folder or files under it.
After this, copy all the original folder that you have backed up
For example:
com.apple.iChat -> to the original place under ~/Library/Containers so here you will have two file com.apple.iChat_old and com.apple.iChat
The same goes for the message folder. However, you have cut, so paste back the file that contains iChat and iMessage back to the Preferences.
DO NOT START THE MESSAGES APP and restart your computer
Open Messages, your old chats should all be there. And sync with your iCloud from Mac and it should come to your iPhone also.
~/Library/Messages