This has vexed me for months. I'm posting this just in case it will help you, too. I have a mostly-stock 2007 Prius Touring with 334k+ miles. A couple of months ago, the alarm would go off in the middle of the night. It was driving me crazy. I changed the battery in the key fob and I knew that the neighborhood cats weren't setting it off. I checked these boards and found that someone replaced this blue+white electrical connector in the back of the Prius below the hatch door: I can't find the post to reference it. However, I separated the blue and white parts by pressing down on the latch on top with a screwdriver. Then, I looked inside this connector and it was discolored from corrosion. I went to my local pick-a-part place and found another 2007 Prius and cut this connector out. I brought it to my local mechanic and had him replace my old one. No more random alarm sounds.
I am dealing with this dreaded problem also. My concern about replacing the rear hatch sensor with a used one is that it will have the same problem. So I am trying to find a new part. Did you ever get a part #? Is this pic the correct part?
I think the "sensor" is part of the lock assembly, which would be this: 2007 toyota Prius Lock assembly, back door. Interior, body, handle, components - 6935047011 - Genuine toyota Part
I haven't replaced anything. But Hyde showed a photo of what he replaced, and you seemed to be asking what part that was, so I supplied its name, its part number, and a link.