The full code of Aware IM UI is in the file AwareIM/Tomcat/webapps/AwareIM/aware_ext/aware_full.js
The filter button is handled in the object called QueryLayoutParser. Search for "filter" within this object and you will find everything to do with this button - it is being added to the "tools" section of the form in the method addTools. You need to take it away from there and put the same button in one of the toolbars - top or bottom.
One important thing is that Aware IM uses the file aware.js, not aware_full.js. The former is the minified version of the latter (to speed up download). So you really need to make the change in the minified version or rename the full version to aware.js