You could be having referred pain to either
location, but more likely in my experience, from the sub-sternum pain. I get a little pain, mostly an itch under left shoulder blade, with no explanation. The vagus verve and others run around everywhere. I have no gallbladder problem that I know of. My ultrasound only shows a little sludge. Only having pain in the middle of the night, not right after eating, sort of sounds more like gallbladder to me. But it could be both!
Endoscopy may or may not show a hernia. It depends on where the stomach is at the time of the scope. A lot of scopes entirely miss or minimize hiatal hernias, again in my experience as a patient. The stomach is empty and can be in the abdomen for the couple of minutes the GI doc is looking. The barium swallow won't miss it because they have you swallowing a contrast dye and you'll reflux in the different positions they put you in. It's much more acurate! But the gastro doc doesn't get paid for that. He has to refer you to a radiologist.
Gallbladder pain could be an explanation too. Ulltrasound is a very good test for that. I would definitely get that first so the doc can decide if you need him to scope up the tube that drains into the small intestine. No use getting scoped twice.
For endoscopy most docs like to have you sedated. I personally always insist on refusing Versed. It's only to give you amnesia, doesn't do anything for pain. I've heard people screaming. They just don't remember it. If you have to have anything - and a lot of people don't!!! ask for propofol so you are really asleep. They don't like to give it because they have to have an anesthesiologist around. The GI doc can give Versed. Propofor wears off immediately and leaves you clear-headed, but Versed makes you loopy for hours, amnesia for whole time.