spservices – DataTables Custom Filter Not Accepting SharePoint IfUserInGroup

I am using DataTables to create a task list on a web-part page that uses AJAX calls to and from different lists.

I currently have one condition that works, where if the currentUserId is the same as the tableUserId, then it only shows that persons tasks. I have a condition outside of the table that determines if the current user is in the “Task Assigners” group, if they are it shows the assign a task button, if not it hides it. If the user is in that group, I want the table to show all items to them, but when I add the condition to the search.push. It still only follows the currentUserTitle condition and not both.

Here is the outside table filter:

var assignButton = document.getElementById('button1');

    function IsCurrentUserMemberOfGroup(groupName, OnComplete) {

    var currentContext = new SP.ClientContext.get_current();
    var currentWeb = currentContext.get_web();

    var currentUser = currentContext.get_web().get_currentUser(); //getting current user and groups for custom filtering of what people can see
    currentContext.load(currentUser);

    var allGroups = currentWeb.get_siteGroups();
    currentContext.load(allGroups);

    var group = allGroups.getByName(groupName);
    currentContext.load(group);

    var groupUsers = group.get_users();
    currentContext.load(groupUsers);

    currentContext.executeQueryAsync(OnSuccess,OnFailure);

    function OnSuccess(sender, args) { //success function for finding current user and group they are in.
        var userInGroup = false;
        var groupUserEnumerator = groupUsers.getEnumerator();
        while (groupUserEnumerator.moveNext()) {
            var groupUser = groupUserEnumerator.get_current();
            if (groupUser.get_id() == currentUser.get_id()) {
                userInGroup = true;
                break;
            }
        }  
        OnComplete(userInGroup);
    }

    function OnFailure(sender, args) {
        OnComplete(false);
    }    
    }

    function IsCurrentUserHasContribPerms() { //if current user is in group, show the assignButton (Task Assigner Group) to only those people.
        IsCurrentUserMemberOfGroup("TaskAssigners", function (isCurrentUserInGroup) {
            if(isCurrentUserInGroup)
            {
                assignButton.style.display = 'inline-block';
            } else {
                assignButton.style.display = 'none';

            }
        });

    }
ExecuteOrDelayUntilScriptLoaded(IsCurrentUserHasContribPerms, 'SP.js');

This works fine for hiding and showing the assignButton, the issue is getting the isCurrentUserInGroup to carry over to the $.fn.dataTable.ext.search.push();..

Directly after the script I have in the beginning of the post comes the following:

var thisUserTitle = $().SPServices.SPGetCurrentUser({ //get the current user Title field (AKA name field)
        fieldName: "Title",
        debug: false
    });
    
    $.fn.dataTable.ext.search.push( //custom filter to only show people 
        function(settings, searchData, index, rowData) {
            var tableUserTitle = searchData(0); //getting the user name for each row of the datatable
            var api = $.fn.dataTable.Api('#taskTable'); //getting the table API
            //console.log(tableUserTitle);
            if (tableUserTitle == thisUserTitle) { //if the current user equals the same user in the task list row, then it only will show that users items to them so they cannot see others tasks
                return true;
            }
            if (isCurrentUserInGroup) { //if current user is in TaskAssigners, show all table results
                return true;
            }
            return false; //if the current user doesn't equal the same user in the task list row, returns false boolean value and nothing shows in the table
        }
    );

Fortunately, the first condition in the push function works like a charm, but I cannot get the current user in group condition to work as well?