On functions orthogonal to invariant subspaces