  We extend the analysis presented in \cite{contini2023a} to higher redshifts,
up to $z=2$, by focusing on the relation between the intracluster light (ICL)
fraction and the halo mass, its dependence with redshift, role played by the
halo concentration and formation time, in a large sample of simulated galaxy
groups/clusters with $13\lesssim \log M_{halo} \lesssim 15$. Moreover, a key
focus is to isolate the relative contributions provided by the main channels
for the ICL formation to the total amount. The ICL fraction at higher redshift
is weakly dependent on halo mass, and comparable with that at the present time,
in agreement with recent observations. Stellar stripping, mergers and
pre-processing are the major responsible channels of the ICL formation, with
stellar stripping that accounts for $\sim 90\%$ of the total ICL, regardless of
halo mass and redshift. Pre-processing is an important process for clusters to
accrete already formed ICL. The diffuse component forms very early, $z\sim
0.6$, and its formation depends on both concentration and formation time of the
halo, with more concentrated and earlier formed haloes that assemble their ICL
earlier than later formed ones. The efficiency of this process is independent
of halo mass, but increases with decreasing redshift, which implies that
stellar stripping becomes more important with time as the concentration
increases. This highlights the link between the ICL and the dynamical state of
a halo: groups/clusters that have a higher fraction of diffuse light are more
concentrated, relaxed and in an advanced stage of growth.
