And no just because Trader Joe's products have TJ trademarks does not mean they are covered by first-sale doctrine, they are still food stuffs. Trademark under first sale-doctrine is more applicable to reselling a professional sports jersey containing the trademark logo/colors of the team.
Do not confuse issues around distributorships, which are contracts that say, I will agree to sell you these goods at wholesale prices so long as you agree not to sell them anywhere I say you can't.
Your example with reselling prescription opiates, is that opiates are a controlled substance, food is not.
Trademark would only be a problem here if what Pirate Joes was selling was counterfeit Trader Joe's goods.
Pirate Joes' core business was perfectly legal in the US. The only way trademark could be a problem is that Pirate Joes might be ruled too close to Trader Joes, and that's the trademark of the business, not the trademark of the items for sale in the store.
That is wrong, according to the case law. Facts here are very different bc TJ product is backed by the TJ guarantee; therefore, although identical TJ product when PJ sells it, it is "materially different" because PJ doesn't back the TJ product. That material change is a trademark violation, especially where PJ is advertising they buy/resell TJ product (impossible and confusing to customers).
Simply look up the case law when first sale doctrine does not apply as a result of material changes to the product because the change in warranty/customer service inherently tied to the product/brand.
Here is a decent article [1]published by the American Bar Association regarding the resale of "genuine" goods (not counterfeit) by unauthorized retailers. Skip to the "warranty policy and unauthorized dealer page" section, then "going to court".
Note the exceptions to first sale doctrine include "material changes" to the trademark good, including non physical changes, then does a decent job of listing those changes recorgnized by the courts.
[1] https://www.americanbar.org/publications/blt/2014/07/01_payn...
Edit: from article regarding non-physical changes to trademark product, "Perhaps most commonly, differences in warranty protection coverage between authorized and unauthorized sales often lead to trademark infringement"
Transfer of prescription medication is a different matter, and these are controlled substances with specific rules around transfer. If you happened to be a pharmacist and happened to have someone with a prescription for a drug, there are some scenarios where you could transfer them.
If you give me an apple, I have no obligation to eat or destroy the apple. I'm free to give it to anyone I wish, either as a whole or in parts.
Reselling your prescription opiates is prohibited by specific laws. No such law exists for food.
Patented inventions for example can be resold or even incorporated into other devices which are then sold and you don't get to control such things.
Definitely seems like a gray area, but the deciding factor appears to be how likely a customer is to confuse the reseller with the original manufacturer. Given the name of the store was "Pirate Joe's", and they in fact played up the idea that they were an unauthorized reseller, it seems like that confusion would be highly unlikely.