Finally killed this massive chunk of code that was copy-pasted from a different part of the file and had to be manually kept up to date with the original π π πͺ
Fired all batch requests at the same time in getMessagesArrayFromIDs and used Promise.all, it's so much faster than waiting for each one to complete before firing the next!
Created apiActions.gmail.getMessagesArrayFromIDs function which returns an array of message objects from an array of message IDs. It fetches them in batches of 100 to make things faster.