We pursue the analysis of nesting statistics in the O(n) loop model on random maps, initiated for maps with the topology of disks and cylinders by Borot, Bouttier and Duplantier (2016), here for arbitrary topologies. For this purpose, we rely on the topological recursion results by Borot, Eynard and Orantin (2011, 2015) for the enumeration of maps in the O(n) model. We characterize the generating series of maps of genus \mathsf{g} with k boundaries and k' marked points which realize a fixed nesting graph. These generating series are amenable to explicit computations in the loop model with bending energy on triangulations, and we characterize their behavior at criticality in the dense and in the dilute phase.