  We present a model explaining both the 4.2 $\sigma$ muon $g-2$ anomaly and
the relic density of dark matter (DM) in which DM interacts with the Standard
Model (SM) via a scalar portal boson $\varphi$ carrying both dark and SM
leptonic numbers, and mediating a nondiagonal interaction between the electron
and muon that allows $e \leftrightarrow \mu$ transitions. The $\varphi$ could
be produced in high-energy electron scattering off a target nuclei in the
reaction $e Z \to \mu Z\varphi$ followed by the prompt invisible decay
$\varphi~\to$~DM particles and searched for in events with large missing energy
accompanied by a single outgoing muon in the final state. Interestingly,
several events with a similar signature have been observed in a data sample of
$\simeq 3\times 10^{11}$ electrons on target collected during 2016-2018 for the
search for light dark matter in the NA64 experiment at the CERN SPS [PRL {\bf
123}, 121801 (2019)]. Attributing so far these events to background allows us
to set first constraints on the $\varphi$ mass and couplings while leaving at
the same time decisively probing the origin of these events and a large
fraction of the remaining parameter space to a near exiting future with the
upgraded NA64 detector or other planned experiments.
