Not here to give advice, just here to say I'm in the exact same position as everything you described lol. 3 H's and 4 P's in M3, with one of the P's being IM. I've got everything else you described (sub-I H, 258, lots of research), and from everything I've been told from people that I've asked about this, they've said that mid-tier academic programs generally don't care about clerkship grades. Top programs definitely tend to care more about getting H's, AOA status, etc., but I've also heard from a bunch of people that had passes on their application without AOA that they still managed to interview at top programs and matched really well. It really depends on what the rest of your application looks like. At the end of the day, IM is still one of the least competitive specialties.
One other factor that can influence things is how your clerkship grades are determined. Were the grades assigned to you by attendings, determined by percentile cutoffs, etc.? That can change how your grades are viewed. If very few people at your school are passing on each rotation (i.e. <5th percentile), that's a very different story than 30-40% of people passing with each rotation (as is the case at my school). I'm just an M4 in a similar boat though, so don't take too much of this to heart since I haven't been through the match yet lol. Just passing on the advice I've been given for a very similar situation.