Default values in tableselect
in_array() returns a boolean (and takes two arguments), whereas Drupal is expecting an array to be passed for the default value.

The default value array needs to be keyed by the same key used for the options array, so in this case uid. The value for each array element should be TRUE or FALSE, to mark the element as checked or unchecked respectively.

$uids[1] = TRUE;
$uids[2] = FALSE;
$uids[3] = TRUE;
// etc.

$form['msg']['accounts'] = array(
  '#type' =&gt; 'tableselect',
  '#header' =&gt; $header,
  '#options' =&gt; $options,
  '#default_value' =&gt; $uids,
  '#empty' =&gt; 'no companies',
); 


EDIT

I haven't tested the following, but since your $uids array contains only the array keys you want checked, and a positive number is automatically cast to a boolean TRUE in PHP, you might get away converting your array in one step:

$uids = drupal_map_assoc($uids);