from typing import Dict
from typing import Union


def parse_websocket_action(data: Dict[str, str]) -> Union[str, None]:
    """
    Returns the websocket action from a given decoded websocket message or None if the action
    doesn't exist or isn't a valid string.
    """

    if isinstance(data, Dict):
        websocket_action = data.get('action', None)

        if websocket_action and isinstance(websocket_action, str):
            return websocket_action

    return None