This is all dependant on you having "Save history when conversations are closed" checked in Messages prefs - otherwise you can find the conversation, but not rejoin it to your main chat window.
Very Late Edit
It appears as of Jan 2021 that the 'Save history' option can not only uncheck itself, but also then grey out, leaving you completely & utterly stuck.
This is apparently done, without informing the user of the consequences, if you enable "Messages in Cloud" in prefs.
Doing so destroys your chances of simple recovery, as the conversation is simultaneously deleted on all devices.
One more bitter lesson in never trusting iCloud to keep your data safe.
The fix for this grand & glorious mess is to:-
Log out of Messages then quit the app
Navigate to ~/Library/Messages/
Enter Time Machine & navigate back in time until before your error.
Select the chat.db file & restore
[alternatively grab this file from any other backup, Backblaze etc.]
Reboot [relog is supposed to work but doesn't.]
If you're lucky, you should be back to sanity.
It took me about 8 attempts before it worked. At one point I had a totally empty Messages & iCloud was refusing to accept my password. That's the point at which I rebooted rather than relogged.
After the reboot it stopped asking me to login & simply went back to as it was before the error, ready signed-in, all messages back.
If you didn't have iCloud Messages switched on, see below.
Recovering the conversation to my iPhone is still work in progress. Switching Messages in cloud & forcing sync has so far been unsuccessful.
I'll check again tomorrow, give it some time….
… Nope:( 24h & a lot of prompting with 'Sync Now' later, it seems the conversation is permanently lost on the phone.
Phone eventually recovered from a 3-week-old iTunes backup. Better than nothing.
iCloud, of course, has thrown the whole conversation away & saved only the very last incarnation of the backup, from last night.
You cannot directly re-open the last conversation you had from the app itself, if you already closed it by hitting the x.
You need to dig in history, it's located at
Conversations are stored by date. You only need to find any one instance of the conversation you are looking for.
Double-clicking that file will reopen it in a separate window in Messages.
Keep that window open, or the next step fails.
To persuade it to reattach to the main window…
Scroll down your conversations list - it will have reappeared in last place.
Select it, it will appear to be empty, but will fill as soon as you click it.
You can now close the extra window.