  Inspired by the experiment from Moresco \& Alboussi\`ere (2004, J. Fluid
Mech.), we study the stability of a liquid metal flow in a rectangular,
electrically insulating duct with a steady homogeneous transverse magnetic
field. The Lorentz force tends to eliminate velocity variations along the
magnetic field, leading to a quasi-two dimensional base flow with Hartmann
boundary layers near the walls perpendicular to the magnetic field, and
Shercliff layers near the walls parallel to the field. Since the Lorentz force
strongly opposes the growth of perturbations with a dependence along the
magnetic field direction too, we represent the flow with Sommeria \& Moreau's
(1982, J. Fluid Mech.) model, a two-dimensional shallow water model with linear
friction accounting for the effect of the Hartmann layer.
  The simplicity of this model makes it possible to study the stability and
transient growth of quasi-two dimensional perturbations over an extensive range
of parameters up to the limit of high magnetic fields, where the Reynolds
number based on the Shercliff layer thickness $Re/H^{1/2}$ becomes the only
relevant parameter. Tollmien-Schlichting waves are the most linearly unstable
mode, with a further unstable mode $H \gtrsim 42$. The flow is linearly
unstable for $Re/H^{1/2}\gtrsim 48350$ and energetically stable for
$Re/H^{1/2}\lesssim 65.32$. Between these two bounds, non-modal quasi-two
dimensional perturbations undergo significant transient growth (between 2 and 7
times more than in the case of a purely 2D Poiseuille flow, and for much more
subcritical values of $Re$). In the limit of a high magnetic field, the maximum
gain $G_{max}$ associated to this transient growth varies as $G_{max} \sim
(Re/Re_c)^{2/3}$ and occurs at time $t_{Gmax}\sim(Re/Re_c)^{1/3}$ for
streamwise wavenumbers of the same order of magnitude as the critical
wavenumber for the linear stability.
