This sentence is grammatically sound. The reason for the apparent disagreement is the following.
The verb предпочитать takes two objects:
- a direct object in the accusative (зелёный чай)
- an optional indirect object in the dative (чёрному [чаю])
For inanimate masculine gender objects, the accusative coincides with the the nominative (зелёный чай) and not genitive (зелёного чая) as it does for animate objects.
The sentence employs an ellipsis that omits the word [чаю] after чёрному like in the English example: John likes black tea and Mary likes green [tea].
Hope this helps clear up the confusion.