Chosen Solution
Which part do I need to buy to fix it? Is the board broken?
The compass on the iPhone 7 series usually becomes faulty after liquid damage. The IC is situated on the top of the logic board near the end of the arm. It is not a part you can just replace as it is soldered to the board.