If this is completely wrong, someone please say so.
The depth will be the smallest dimension, yes? So I would let d be the depth of the compartment. The volume should then be:
d(d+1)(d+3) = 8
If my math is right, that simplifies to d^3 + 4d^2 + 3d - 8 = 0. Notice that the left side is also equal to zero when d = 1. So you can use synthetic division with (d - 1) as the divisor.
Edit: Now that I read it again, they probably wanted the volume equation in terms of the width. The equation changes, but you use (w - 2) as a divisor, and get the same dimensions in the end.
Comment