diff --git src/wp-admin/includes/ajax-actions.php src/wp-admin/includes/ajax-actions.php
index 170eb96..0992aa0 100644
--- src/wp-admin/includes/ajax-actions.php
+++ src/wp-admin/includes/ajax-actions.php
@@ -2398,7 +2398,9 @@ function wp_ajax_query_attachments() {
 		$query['post_status'] .= ',private';
 
 	// Filter query clauses to include filenames.
-	add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
+	if ( isset( $query['s'] ) ) {
+		add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
+	}
 
 	/**
 	 * Filters the arguments passed to WP_Query during an Ajax
diff --git src/wp-admin/includes/post.php src/wp-admin/includes/post.php
index b12aa5d..c352cbc 100644
--- src/wp-admin/includes/post.php
+++ src/wp-admin/includes/post.php
@@ -1145,7 +1145,9 @@ function wp_edit_attachments_query_vars( $q = false ) {
 	}
 
 	// Filter query clauses to include filenames.
-	add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
+	if ( isset( $q['s'] ) ) {
+		add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
+	}
 
 	return $q;
 }
@@ -1164,12 +1166,14 @@ function _filter_query_attachment_filenames( $clauses ) {
 	global $wpdb;
 	remove_filter( 'posts_clauses', __FUNCTION__ );
 
-	$clauses['join'] = " INNER JOIN {$wpdb->postmeta} ON ( {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id )";
+	// Add a LEFT JOIN of the postmeta table so we don't trample existing JOINs.
+	$clauses['join'] .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )";
+
 	$clauses['groupby'] = "{$wpdb->posts}.ID";
 
 	$clauses['where'] = preg_replace(
 		"/\({$wpdb->posts}.post_content (NOT LIKE|LIKE) (\'[^']+\')\)/",
-		"$0 OR ( {$wpdb->postmeta}.meta_key = '_wp_attached_file' AND {$wpdb->postmeta}.meta_value $1 $2 )",
+		"$0 OR ( sq1.meta_value $1 $2 )",
 		$clauses['where'] );
 
 	return $clauses;
diff --git tests/phpunit/tests/query/search.php tests/phpunit/tests/query/search.php
index d0a34a6..9571733 100644
--- tests/phpunit/tests/query/search.php
+++ tests/phpunit/tests/query/search.php
@@ -384,6 +384,40 @@ class Tests_Query_Search extends WP_UnitTestCase {
 		$this->assertNotEquals( array( $attachment ), $q->posts );
 	}
 
+	/**
+	 * @ticket 22744
+	 */
+	public function test_include_file_names_in_attachment_search_with_meta_query() {
+		$attachment = self::factory()->post->create( array(
+			'post_type'    => 'attachment',
+			'post_status'  => 'publish',
+			'post_title'   => 'bar foo',
+			'post_content' => 'foo bar',
+			'post_excerpt' => 'This post has foo',
+		) );
+
+		add_post_meta( $attachment, '_wp_attached_file', 'some-image4.png', true );
+		add_post_meta( $attachment, '_test_meta_key', 'value', true );
+		add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
+
+		// Pass post_type a string value.
+		$q = new WP_Query( array(
+			's'           => 'image4',
+			'fields'      => 'ids',
+			'post_type'   => 'attachment',
+			'post_status' => 'inherit',
+			'meta_query'  => array(
+				array(
+					'key'     => '_test_meta_key',
+					'value'   => 'value',
+					'compare' => '=',
+				),
+			),
+		) );
+
+		$this->assertSame( array( $attachment ), $q->posts );
+	}
+
 	public function filter_posts_search( $sql ) {
 		return $sql . ' /* posts_search */';
 	}
