  We compute the (center-of-mass frame) scattering angle $\chi$ of
hyperboliclike encounters of two spinning black holes, at the fourth
post-Newtonian approximation level for orbital effects, and at the
next-to-next-to-leading order for spin-dependent effects. We find it convenient
to compute the gauge-invariant scattering angle (expressed as a function of
energy, orbital angular momentum and spins) by using the Effective-One-Body
formalism. The contribution to scattering associated with nonlocal, tail
effects is computed by generalizing to the case of unbound motions the method
of time-localization of the action introduced in the case of
(small-eccentricity) bound motions by Damour, Jaranowski and Sch\"afer [Phys.\
Rev.\ D {\bf 91}, no. 8, 084024 (2015)].
