I am using the Ruby IMAP library to get a GMail conversation. The way that GMail threads conversations is via \"Message-ID\" and \"In-Reply-To\" message headers. For example:
Apparently, the correct way to do this is:
imap.search ["HEADER", "MESSAGE-ID", target]