The hide command just sets the visibility attribute on the mesh. So you just need to query that attribute to test if an object is hidden or not.
hide pCube1;
getAttr pCube1.visibility;
// Result: 0 //
showHidden pCube1;
getAttr pCube1.visibility;
// Result: 1 //
g-