Grammerly's wrong. You don't want one at the end of the sentence. If that's the sentence you want to write, I think you're better without a question-mark at all.
But since you're aware there's a problem with it, I'd be inclined to recast it. "They wondered if it had arrived." - clear, simple, same information, no doubtful punctuation, no issues.