Repository: nushell/nushell (language: rust)

Issue:
Can no longer `reject` rows in a flattened table/list (regression in main)
### Describe the bug

`reject` now errors when passed a list that has been `flatten`ed.

Note that this causes `std-rfc/tables` to fail.  Noticed this when moving it over from the "old" `std-rfc` to the latest.

### How to reproduce

```nushell
[[N, u, s, h, e, l, l]] | flatten | reject 1
# => Error: nu::shell::not_a_list
# => 
# =>   × Not a list value
# =>    ╭─[entry #33:1:3]
# =>  1 │ [[N, u, s, h, e, l, l]] | flatten | reject 1
# =>    ·   ┬                                        ┬
# =>    ·   │                                        ╰── value not a list
# =>    ·   ╰── value originates here
# =>    ╰────
```

This works in 0.101.

It also fails even if the before-and-after flattened table are "equal":

```nushell
let list = [N, u, s, h, e, l, l]
let nested_list = [[N, u, s, h, e, l, l]]
$list == ($nested_list | flatten)
# => true

$list | reject 1
# => ╭───┬───╮
# => │ 0 │ N │
# => │ 1 │ s │
# => │ 2 │ h │
# => │ 3 │ e │
# => │ 4 │ l │
# => │ 5 │ l │
# => ╰───┴───╯

$nested_list | flatten | reject 1
# => Error: nu::shell::not_a_list
# => 
# =>   × Not a list value
# =>    ╭─[entry #38:1:21]
# =>  1 │ let nested_list = [[N, u, s, h, e, l, l]]
# =>    ·                     ┬
# =>    ·                     ╰── value originates here
# =>    ╰────
# =>    ╭─[entry #41:1:33]
# =>  1 │ $nested_list | flatten | reject 1
# =>    ·                                 ┬
# =>    ·                                 ╰── value not a list
# =>    ╰────
```

### Expected behavior

Works as in 0.101 and rejects the item without error.

### Configuration

| key                | value                                    |
| ------------------ | ---------------------------------------- |
| version            | 0.101.1                                  |
| major              | 0                                        |
| minor              | 101                                      |
| patch              | 1                                        |
| branch             | main                                     |
| commit_hash        | f88ed6ecd52c167485f50f1c1bd9dea2d2d8fc04 |
| build_os           | linux-x86_64                             |
| build_target       | x86_64-unknown-linux-gnu                 |
| rust_version       | rustc 1.82.0 (f6e511eec 2024-10-15)      |
| rust_channel       | 1.82.0-x86_64-unknown-linux-gnu          |
| cargo_version      | cargo 1.82.0 (8f40fc59f 2024-08-21)      |
| build_time         | 2025-01-26 08:27:20 -05:00               |
| build_rust_channel | release                                  |
| allocator          | mimalloc                                 |
| features           | default, sqlite, trash                   |
| installed_plugins  | formats 0.101.0, gstat 0.101.1           |


Discussion / hints:
Seems like the difference is based on whether the input is a stream or not. This also works
```nushell
[[N, u, s, h, e, l, l]] | flatten | collect | reject 1
# => ╭───┬───╮
# => │ 0 │ N │
# => │ 1 │ s │
# => │ 2 │ h │
# => │ 3 │ e │
# => │ 4 │ l │
# => │ 5 │ l │
# => ╰───┴───╯
```
Looks like this is probably due to #14622 then - Checking now.

Fix patch:
diff --git a/crates/nu-command/src/filters/reject.rs b/crates/nu-command/src/filters/reject.rs
index e15c6b65e4b2e..b728ca828e0bc 100644
--- a/crates/nu-command/src/filters/reject.rs
+++ b/crates/nu-command/src/filters/reject.rs
@@ -220,8 +220,14 @@ fn reject(
 
     new_columns.append(&mut new_rows);
 
+    let has_integer_path_member = new_columns.iter().any(|path| {
+        path.members
+            .iter()
+            .any(|member| matches!(member, PathMember::Int { .. }))
+    });
+
     match input {
-        PipelineData::ListStream(stream, ..) => {
+        PipelineData::ListStream(stream, ..) if !has_integer_path_member => {
             let result = stream
                 .into_iter()
                 .map(move |mut value| {


Test patch:
diff --git a/crates/nu-command/tests/commands/reject.rs b/crates/nu-command/tests/commands/reject.rs
index a2c052b3e1747..47c5e86452296 100644
--- a/crates/nu-command/tests/commands/reject.rs
+++ b/crates/nu-command/tests/commands/reject.rs
@@ -178,3 +178,10 @@ fn test_ignore_errors_flag_var() {
         nu!("let arg = [5 c]; [[a, b]; [1, 2], [3, 4], [5, 6]] | reject ...$arg -i | to nuon");
     assert_eq!(actual.out, "[[a, b]; [1, 2], [3, 4], [5, 6]]");
 }
+
+#[test]
+fn test_works_with_integer_path_and_stream() {
+    let actual = nu!("[[N u s h e l l]] | flatten | reject 1 | to nuon");
+
+    assert_eq!(actual.out, "[N, s, h, e, l, l]");
+}