def getUsersWithCompetencies(categories, usercompetencies):
    """
    Lists competences and their corresponding user IDs and returns the user ID
    matching the needed competence

    :param categories: Needed competence category
    :type categories: list
    :param usercompetencies: User IDs and their competences
    :type usercompetencies: dict
    """
    competencies = {}
    for user in usercompetencies:
        for competence in usercompetencies[user]:
            if competence not in competencies:
                competencies[competence] = []
                competencies[competence].append(user)
            else:
                competencies[competence].append(user)
    for competence in categories:
        if competence in competencies:
            return {'competence': competence, 'users': competencies[competence]
                }
    return None
