In combat, can squeeze thru a 10' door; out of combat, DM's adjudication
The Player's Handbook has rules for "squeezing" - a character normally requires a space fit for their size (5' for Medium, etc), but can "squeeze" into a space for one size smaller at the cost of it costing extra movement, causing disadvantage, etc.
However, these rules are clearly meant to help adjudicate combat in narrow spaces, or other tense moments where you're trying to move quickly. They don't reasonably apply when the character is at ease.
For example, per these rules a Medium character, like a human, can only squeeze into the space of a Small creature, which is still 5'; they can't go thru 2.5' spaces at all. But in reality, a 2.5' wide hallway, while narrow, is perfectly walkable by an average human; you might brush your arms on the walls, and dashing down it would be troublesome, but that's it. Even a 1' corridor can be used by most people, it just requires a sideways shuffle.
(I recall squeezing myself thru my family home's doggy door many times as a teen, when I'd forget my keys. It was about 1' x 1.5'. Required some gymnastics, but doable.)
So, back to the question at hand - what can a Giant Ape fit thru? Huge creatures are, roughly, 4x larger in every dimension than a Medium creature. This suggests a width of at least 10' across the shoulders (and for an Ape, you probably want to round that up a bit), and a depth, when standing as straight as an Ape can, of at least 4-5'.
So I'd personally say that a Giant Ape could, with effort, squeeze thru a 5' wide door. They'd have to shimmy on the ground for it, tho, and it would take several actions. Note that human-sized doors are not 5' wide, they're usually about 3' wide; I'd rule against squeezing thru that without damaging the doorframe.
So as long as your dungeon has fairly wide doors (or just double doors), the ape could get thru.