This relation holds if the horizontal dimensions of the ocean volume under consideration are much larger than the vertical dimension, hence the shallow water designation.
As we will see in section 2.1, the pressure gradients associated with the free surface elevation are constant with depth. Thus they form part of the zeroth mode or the vertically-averaged mode, and appear only in the barotropic mode equations. Consequently, the baroclinic system representing the higher-order modes has no surface elevation associated with it, and the corresponding surface boundary condition is that of a rigid lid.
A particular form of the baroclinic models are the so-called reduced gravity models. These are essentially isopycnal models of several deformable layers where the lowest layer has infinite depth and zero velocity. Clearly no barotropic mode is associated with such models, and although the motions are driven by the density differences between layers, there are restrictions on the motions and interface deformations. For example, in a two-layer reduced gravity (RG) model the deviations of the interface between the two layers (representing excursions of the pycnocline) are multiples of the free surface elevation, by a factor which is proportional to the ratio , being the density and the density difference between the two layers (the lower one being heavier, of course).
We will discuss the barotropic models in the next section and the reduced gravity models in section 3.