How do I display a history of messages between two users using the Privatemsg module?
The OP succeeded in doing this by creating a helper function in a custom module.

The function accepts two arguments, the sender uid and the recipient uid.  It returns the list of messages. 

Then one can call this function from anywhere to get the required list of messages.

Here is the function the OP created:

function get_message_history($sender_uid, $recipient_uid) {
  $query = db_query("SELECT * FROM pm_index, pm_message
    WHERE ((pm_index.recipient = $sender_uid AND pm_message.author = $recipient_uid)
      OR (pm_index.recipient = $recipient_uid AND pm_message.author = $sender_uid))
      AND pm_index.mid = pm_message.mid
    ORDER BY pm_message.timestamp DESC");
  $messages = $query-&gt;fetchAll();
  return $messages;
}