We investigate the alignment of haloes with the filaments of the cosmic web using an unprecedently large sample of dark matter haloes taken from the P-Millennium ΛCDM cosmological N-body simulation. We use the state-of-the-art NEXUS morphological formalism which, due to its multiscale nature, simultaneously identifies structures at all scales. We find strong and highly significant alignments, with both the major axis of haloes and their peculiar velocity tending to orient along the filament. However, the spin -filament alignment displays a more complex trend changing from preferentially parallel at low masses to preferentially perpendicular at high masses. This "spin flip" occurs at an average mass of 5 × 10 11 h −1 M . This mass increases with increasing filament diameter, varying by more than an order of magnitude between the thinnest and thickest filament samples. We also find that the inner parts of haloes have a spin flip mass that is several times smaller than that of the halo as a whole. These results confirm that recent accretion is responsible for the complex behaviour of the halo spin -filament alignment. Low-mass haloes mainly accrete mass along directions perpendicular to their host filament and thus their spins tend to be oriented along the filaments. In contrast, high-mass haloes mainly accrete along their host filaments and have their spins preferentially perpendicular to them. Furthermore, haloes located in thinner filaments are more likely to accrete along their host filaments than haloes of the same mass located in thicker filaments.