  In this work, we combine the semi-analytic model of galaxy formation and
evolution SAG with the $102$ relaxed simulated galaxy clusters from The Three
Hundred project, and we study the link between the quenching of star formation
(SF) and the physical processes that galaxies experience through their
dynamical history in and around clusters. We classify galaxies in four
populations based on their orbital history: recent and ancient infallers, and
backsplash and neighbouring galaxies. We find that $\sim 85$ per cent of the
current population of quenched galaxies located inside the clusters are ancient
infallers with low or null content of hot and cold gas. The fraction of
quenched ancient infallers increases strongly between the first and second
pericentric passage, due to the removal of hot gas by the action of
ram-pressure stripping (RPS). The majority of them quenches after the first
pericentric passage, but a non-negligible fraction needs a second passage,
specially galaxies with $M_\star \leq 10^{10.5} \, {\rm M_\odot}$. Recent
infallers represent $\sim 15$ per cent of the quenched galaxies located inside
the cluster and, on average, they contain a high proportion of hot and cold
gas; moreover, pre-processing effects are the responsible for quenching the
recent infallers prior to infall onto the main cluster progenitor. The $\sim
65$ per cent of quenched galaxies located around clusters are backsplash
galaxies, for which the combination of RPS acting during a pre-processing stage
and inside the cluster is necessary for the suppression of SF in this
population.
