That didn't save him from being nibbled by rats and fleas all night and getting so wet and cold his knees "refused to do their office" the next morning.

Does this "refused to do their office" mean ''fail to move"?

Thanks for your help!
"refused to do their office" is not a phrase I'm familiar with, but in context I would say that you are basically correct, and the author is saying that because "he" is got so wet and cold that his knees wouldn't allow him to stand up.
Thanks free_spirit!