You know, I've recently realized that beaming all those tribbles to the Klingon ship at once -- in either tribble episode -- should've constituted a far more destructive attack than what was shown. Beaming in all that volume of matter would require displacing a lot of air within the ship, which would cause a sudden increase in pressure within the ship. At the very least, the overpressure shock could've harmed members of the crew; at worst, a sudden overpressure within a pressurized vessel in vacuum could cause a hull rupture, like an exploding water heater.
“All that volume of matter” is probably much less than the water Scotty beams aboard a BOP in TVH. I don’t think there’s anything canonic that addresses how the transporter handles whatever is being displaced on the other end, but presumably it handles it somehow. We never hear the loud bang that I think would result from leaving a vacuum in the place of whatever just beamed away, so it may be that whatever is beamed simply swaps places with the air being displaced at the other end of the transport.