As all three boxes were labelled incorrectly there will only be 2 ways of doing this.
Say this is correct order
1. Nails 2. Nails and screws 3.screws
No dearrangments will be
1.S 2.N 3.N&S
And
1.N&S 2.S 3.N
So we will get the actual arrangememt by doing either doing two swaps ( 1&2, 2&3) for dearrangement 1 or four swaps (1&2,2&3) again (1&2,2&3) for dearrangement 2.
So after doing two swaps we can take an item from a box and check. If it turn outs to be the wrong one. Then make two swaps. And we will get the actual arrangememt.