In combat, it 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 proportionate to their size (5' for Medium, etc.), but can "squeeze" into a space one size smaller with 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 they're trying to move quickly. The rules don't reasonably apply when the character is at ease.
For example, per these rules a Medium character, like a human, can squeeze into nothing smaller than 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 through 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 through? Huge creatures are, roughly, 4x larger in each 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 through a 5' wide door. They'd have to shimmy on the ground for it, though, 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 through the latter without damaging the doorframe.
So as long as your dungeon has fairly wide doors (or just double doors), the ape could get through.